自己写的动画接口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 

你可能感兴趣的:(自己写的动画接口runAction RepeatForever cc.Animate cc.Animation)