spriteEx.lua function Sprite:playAnimationOnce(animation, removeWhenFinished, onComplete, delay) return transition.playAnimationOnce(self, animation, removeWhenFinished, onComplete, delay) end function Sprite:playAnimationForever(animation, delay) return transition.playAnimationForever(self, animation, delay) end
local MainScene = class("MainScene", function() return display.newScene("MainScene") end) function MainScene:ctor() local sp=display.newSprite("1.png",200 ,200); self:add(sp) local animation=cc.Animation:create() animation:addSpriteFrameWithFile("1.png") animation:addSpriteFrameWithFile("2.png")
--这一句话必须写,不写没有效果 animation:setDelayPerUnit(1)
--这一句话中的1是延时一秒后播放 sp:playAnimationForever(animation,1) sp:playAnimationOnce(animation, removeWhenFinished, onComplete, delay) end return MainScene