Node游戏循环和事件调度

Node类封装了Scheduler类,可以使用定时器对对象的运行进行调度。

local MainScene = class("MainScene", cc.load("mvc").ViewBase)

function MainScene:onCreate()
    self.lab = cc.Label:createWithSystemFont("Hello World", "Arial", 40)
        :move(display.cx, display.cy + 200)
        :addTo(self)

    --第一个为执行的方法,第二个为多少时间s执行一次
    self:scheduleUpdateWithPriorityLua(handler(self,self.update),1/60)
    --self:unscheduleUpdate()  停止调度

end

function MainScene:update()
    self.lab:setRotation(self.lab:getRotation() + 1)
end

return MainScene

首页 我的博客
粤ICP备17103704号