Cocos2d_x + Lua [7] -- touch screen event

Source: Internet
Author: User

Odustggg Personal Original, welcome to reprint, reprint please indicate the source, http://blog.csdn.net/odustggg/article/details/8192869
To enable the cclayer touch screen, you only need two steps.

-- Override the corresponding touch function pttouchbegan = nil pttouchend = nillocal function ontouchbegan (x, y) pttouchbegan = ccpointmake (x, y) endlocal function ontouchmoved (x, y) end local function ontouchended (x, y) pttouchend = ccpointmake (x, y) pttouchbegan = nil pttouchend = nilendlocal function ontouch (eventtype, x, y) if eventtype = cctouchbegan then return ontouchbegan (x, y) elseif eventtype = cctouchmoved then return ontouchmoved (x, y) else return ontouchended (x, y) endend -- register the touch function layer: registerscripttouchhandler (ontouch) -- set to touchable layer: setistouchenabled (true)

If ccscene needs to implement a touch screen, it is enough to save the registration touch function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.