cocos2dx lua 触摸事件+计时器

来源:互联网 发布:什么是网络直销模式 编辑:程序博客网 时间:2024/05/22 00:09
cocos2dx lua 触摸事件


    local function onTouchBegin(touch, event)
        cclog("触摸开始");
        self:m_onTouchBegin(touch, event);
        return true
    end
    local function onTouchMoved(touch, event)
    end
    local function onTouchEnd(touch, event)
    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 计时器
    cc.Director:getInstance():getScheduler():scheduleScriptFunc(callBack, 3, false)
原创粉丝点击