导入编辑器生成的lua文件
local result = require("导出文件名").create()
self:addChild(result.root)
从studio导入文件中获取对应的控件
local button = ccui.Helper:seekWidgetByTag(self, 逻辑标签)
定时器
self.scene:scheduleUpdate(handler(self, self.step))
function PlayerScene:step(dt)
end
触摸的回调函数
local listener = cc.EventListenerTouchOneByOne:create()
listener:registerScriptHandler(handler(self, self.onTouchBegan), cc.Handler.EVENT_TOUCH_BEGAN)
self.scene:getEventDispatcher():addEventListenerWithSceneGraphPriority(listener, self.scene)
function PlayerScene:onTouchBegan(touch, event)
return true
end
按键监听函数,code=6是安卓的返回键
local function onrelease(code,event)
if code == cc.KeyCode.KEY_BACK then
end
end
local listener = cc.EventListenerKeyboard:create()
listener:registerScriptHandler(onrelease,cc.Handler.EVENT_KEYBOARD_RELEASED)
self:getEventDispatcher():addEventListenerWithSceneGraphPriority(listener,self)