local scheduler = require(cc.PACKAGE_NAME .. ".scheduler") local MainScene = class("MainScene", function() return display.newScene("MainScene") end) local interval=0 function MainScene:ctor() self.box=display.newSprite("box.png",display.cx,display.cy):addTo(self) self:addNodeEventListener(cc.NODE_ENTER_FRAME_EVENT,handler(self , self.update)) self:scheduleUpdate() end function MainScene:update( dt ) interval=interval+1 print(interval) if interval>10 and interval<=20 then self.box:setColor(cc.c3b(255,0,0)); elseif interval>20 and interval<=30 then self.box:setColor(cc.c3b(255,255,255)) elseif interval>30 and interval<=40 then self.box:setColor(cc.c3b(255,0,0)); elseif interval>40 and interval<=50 then self.box:setColor(cc.c3b(255,255,255)) elseif interval>50 then self:unscheduleUpdate() end end return MainScene