先要用TP进行把数据压,生成帧动画大图
代码如下:
cc.SpriteFrameCache:getInstance():addSpriteFrames(("yin.plist"))
播放动画
function GameClientEngineM:palyWinerAnimation(iWinerID)
-- body
--创建帧动画
local animate = cc.Animation:create()
for i = 1, 4 do
local frameName = "yin"..i..".png"
animate:addSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(frameName))
end
animate:setDelayPerUnit(0.3) --时间间隔
animate:setRestoreOriginalFrame(true) --是否播放完后回到第一针
animate:setLoops(3) --循环册书
local action = cc.Animate:create(animate)
local test = cc.Sprite:createWithSpriteFrameName("yin1.png")
test:runAction(cc.Sequence:create(action, cc.CallFunc:create(function()
-- body
if test ~= nil then
--todo
test:removeFromParent()
test = nil
end
end)))
test:setPosition(self:_Player_BG[iWinerID]:getPosition())
test:addTo(self._gameLayer)
--
end