LocalScheduler =require(CC. Package_name.". Scheduler")LocalMainscene = Class ("Mainscene",function() returnDisplay.newscene ("Mainscene")End)functionmainscene:ctor () display.addspriteframes ("bandit.plist","Bandit.png") Self.hero_=display.newsprite ("#player_idle1. png", display.cx,display.cy): AddTo (self) self.status="Play"Self.isplay="No"Scheduler.scheduleupdateglobal (function() ifself.status=="Play" Then ifself.isplay~="playing" Then LocalFrames = Display.newframes ("Player_run%1d.png",1,6) LocalAnimation = Display.newanimation (frames,0.1) LocalAnimate=cc. Animate:create (animation) Self.repeatanimate=cc. Repeatforever:create (animate) self.hero_:runAction (self.repeatanimate) Self.isplay="playing" End Elseself.hero_:stopAction (self.repeatanimate) Self.isplay="No" End End ) LocalLayer =Display.newlayer (): AddTo (self) layer:settouchenabled (true) Layer:settouchmode (CC. Touch_mode_one_by_one) Layer:addnodeeventlistener (CC. Node_touch_event,function(Event)LocalX, Y, PrevX, Prevy =event.x, Event.y, Event.prevx, Event.prevyifEvent.name = ="began" Then ElseIfEvent.name = ="moved" Then ElseIfEvent.name = ="ended" Then ifself.status=="Play" ThenSelf.status="Stop" ElseSelf.status="Play" End End return true End) EndreturnMainscene
Quick Cocos Animate Manage