–监听手机返回键
local key_listener = cc.EventListenerKeyboard:create()
–返回键回调
local function key_return(keycode)
print(keycode)
if keycode ~= cc.KeyCode.KEY_BACKSPACE then
–return
end
local sence = cc.Director:getInstance():getRunningScene()
local chlid = sence:getChildren()
chlid#chlid]:Toback()
-- print("EVENT_KEYBOARD_PRESSED")
end
--lua中得回调,分清谁绑定,监听谁,事件类型是什么
key_listener:registerScriptHandler(key_return,cc.Handler.EVENT_KEYBOARD_PRESSED)
local eventDispatch = self:getEventDispatcher()
eventDispatch:addEventListenerWithSceneGraphPriority(key_listener,self)
按键 监听 在真机上 没有反应, 在window下测试正常
求助怎么解决