cocos2dx for lua 简单的翻牌动画

    local x = 20

    local y = display.height/2

 

for i = 1,16 do--创建16张

        local cardFg = display.newSprite("cardFg.png",x+(i*70),y)--背景牌

        self:addChild(cardFg,0)

        cardFg:setVisible(false)

 

        local cardBg = display.newSprite("cardBg.png",x+(i*70),y)--前景牌

        self:addChild(cardBg,1)

 

        self:runAction(cc.Sequence:create(cc.DelayTime:create(1 + i * 0.5),cc.CallFunc:create(function()

            openCard(cardBg,cardFg)

        end)))

end

end

 

function openCard(cardBg,cardFg)

    local time = 1

    cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D)--cocos2d::DisplayLinkDirector::Projection::_2D

    cardBg:runAction(cc.Sequence:create(cc.OrbitCamera:create(time,1,0,0,90,0,0),cc.Hide:create(),cc.CallFunc:create(--开始角度设置为0,旋转90度

        function()

            cardFg:runAction(cc.Sequence:create(cc.Show:create(),cc.OrbitCamera:create(1,1,0,270,90,0,0)))--开始角度是270,旋转90度

        end

    )))

end

文章来自:http://www.cnblogs.com/HemJohn/p/5001683.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3