cocos2dx_lua键盘监听
开发环境:cocos2dx 3.17
开发语言:lua
这里用lua实现对键盘的监听
下面直接上代码吧
local function keyboardPressed(KeyCode,event)
print(KeyCode)
end
local function keyboardReleased(KeyCode,event)
end
local listener = cc.EventListenerKeyboard:create()
listener:registerScriptHandler(keyboardPressed, cc.Handler.EVENT_KEYBOARD_PRESSED)
listener:registerScriptHandler(keyboardReleased, cc.Handler.EVENT_KEYBOARD_RELEASED)
local eventDispatcher = self:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener,self)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 三尺青锋!
评论