lua 播放帧动画

本文详细介绍了如何利用TP技术将数据压缩并生成帧动画大图,包括具体的代码实现步骤,如加载资源、创建动画帧、设置动画参数等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

先要用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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值