自己写的动画接口runAction RepeatForever cc.Animate cc.Animation

local action = cc.Animate:create(animation)
local cache = cc.AnimationCache:getInstance()

function LoginScene:amTest()
    
    local cache = cc.SpriteFrameCache:getInstance()
    cache:addSpriteFrames("res/common/bg/am.plist", "res/common/bg/am.png")
    
    local _pSprite1 = cc.Sprite:createWithSpriteFrameName("Drone1_000.png")
    _pSprite1:setPosition(cc.p(150, 50))
    
    local animFrames = {}
    for i = 0, 9 do
        local frame = cache:getSpriteFrame(string.format("Drone1_%03d.png", i))
        animFrames[i] = frame
    end
    
    local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3)
    _pSprite1:runAction(cc.RepeatForever:create(cc.Animate:create(animation)))
    self:addChild(_pSprite1)

    cca.builder()
        :begin("spawn")
            :moveTo(4, 150, 500)
        :done()
        :removeSelf()
        :addTo(_pSprite1)


    -- cc.Director:getInstance():getTextureCache():removeTextureForKey("res/common/bg/am.png")
    -- cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile("res/common/bg/am.plist")
end 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容