lua(cocos)粒子/动画

function YQWBaseGameScene:showGoodLuckEffect(drawIndex)
    if not drawIndex then return end
    local nodeRoot = self:getNodeGoodLuckShow()
    if nodeRoot then
        local goodLuckNode   = cc.CSLoader:createNode("res/gamecocosstudio/csb/ani_others/ani_goodluck.csb")
        if goodLuckNode then
            nodeRoot:addChild(goodLuckNode)
            local goodLuckAni = cc.CSLoader:createTimeline("res/gamecocosstudio/csb/ani_others/ani_goodluck.csb")
            if goodLuckAni then
                local starAni = goodLuckNode:getChildByName("animation_star")
                if starAni then
                    starAni:setVisible(false)
                end

                goodLuckNode:runAction(goodLuckAni)
                goodLuckAni:gotoFrameAndPlay(0, 101, false)

                local function frameCallFunc(frame)
                    if frame and "Play_Particle" == frame:getEvent() then
                        local dstPlayer = self:getNodePlayer(drawIndex)
                        if not dstPlayer then return end
                       
                        if starAni then
                            starAni:setVisible(true)
                        end

                        local aniMoveTo = cc.MoveTo:create(1, nodeRoot:convertToNodeSpace(cc.p(dstPlayer:getPosition())))
                        local scale  = cc.ScaleTo:create(0.8, 0.1)
                        local action = cc.Spawn:create(aniMoveTo, scale)
                        goodLuckNode:runAction(action)  --cc.Sequence:create(aniMoveTo, fadeOut)
                    elseif frame and "Play_Star" == frame:getEvent() then
                        if starAni then
                            starAni:setVisible(false)
                        end
                          
                    elseif frame and "Play_Over" == frame:getEvent() then
                        goodLuckAni:clearFrameEventCallFunc()
                        goodLuckNode:setVisible(false)
                        goodLuckNode:getParent():removeChild(goodLuckNode, true)
                        goodLuckNode = nil
                        if gameController then
                            gameController:finishedGoodLuckAni()
                        end
                       
                    end
                end
                goodLuckAni:setFrameEventCallFunc(frameCallFunc)
            end
        end
    end
end
    local emitter1 = cc.ParticleExplosion:createWithTotalParticles(130) 
   -- local emitter1 = cc.ParticleSun:createWithTotalParticles(60)
    emitter1:setAutoRemoveOnFinish(true)
    emitter1:setPosition(dstPlayer:convertToNodeSpace(cc.p(dstPlayer:getPosition())))
    emitter1:setTexture(cc.Director:getInstance():getTextureCache():addImage("res/gamecocosstudio/plist/animation/pplz.png")) --加载图片
    dstPlayer:addChild(emitter1, 100)
    emitter1:setLife(0.1)
    local dstPlayer = self:getNodePlayer(drawIndex)
    local emitter1 = cc.ParticleSystemQuad:create("res/gamecocosstudio/plist/animation/bglz.plist")--加载粒子动画
    emitter1:setAutoRemoveOnFinish(true) 
    emitter1:setPosition(cc.p(dstPlayer:getPosition()))
    dstPlayer:addChild(emitter1, 100)
    emitter1:setDuration(0.5)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值