수신 키 반환 - Quick-Cocos2dx
1633 단어 cocos2dlua
function FightScene:onKeyboard(code, event)
if code == cc.KeyCode.KEY_BACK then
print(" ")
GameApp:enterScene("MainScene");
end
end
function FightScene:onEnter()
self.keyListener = cc.EventListenerKeyboard:create()
--handler(self,self.onKeyboard) , handler
self.keyListener:registerScriptHandler(handler(self,self.onKeyboard),cc.Handler.EVENT_KEYBOARD_RELEASED)
local eventDispatch = self:getEventDispatcher()
eventDispatch:addEventListenerWithSceneGraphPriority(self.keyListener,self)
end