수신 키 반환 - 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

좋은 웹페이지 즐겨찾기