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.