cocos2dx_lua 触摸监听

cocos2dx_lua 触摸监听 
   local function onTouchBegin()
        cclog("onTouchBegin");
        return true
    end
    local function onTouchMoved()
        cclog("onTouchMoved");
    end
    local function onTouchEnd()
       cclog("onTouchEnd");
    end
    local listener = cc.EventListenerTouchOneByOne:create();
    listener:setSwallowTouches(true);
    listener:registerScriptHandler(onTouchBegin, cc.Handler.EVENT_TOUCH_BEGAN);
    listener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED);
    listener:registerScriptHandler(onTouchEnd, cc.Handler.EVENT_TOUCH_ENDED);
    local eventDispatcher = self:getEventDispatcher()
    eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self);

你可能感兴趣的:(cocos2dx,lua)