Cocos2d-x动画,翻开,翻页,淡入淡出动画

这是一个Coco2d-x的翻开动画,跟翻书一样翻成另外一张图片:

--翻开动画
function open(Sprite,func)
    local array = CCArray:create()
    array:addObject(CCDelayTime:create(1))
    array:addObject(CCScaleTo:create(0.3,0,Sprite:getScaleY()))
    array:addObject(CCCallFuncN:create(func))
    array:addObject(CCScaleTo:create(0.3,Sprite:getScaleX(),Sprite:getScaleY()))
    Sprite:runAction(CCSequence:create(array))
end


Sprite是一张图片,func是回调方法


这是一淡出效果:

local secondAction = CCSequence:createWithTwoActions(CCFadeOut:create(2), CCCallFuncN:create(showTqIcon))
    local  action = CCSequence:createWithTwoActions(CCDelayTime:create(30),secondAction)
    iconTqimage:runAction(action)


这是一个淡入效果

local secondAction = CCSequence:createWithTwoActions(CCDelayTime:create(2), CCCallFuncN:create(showTqIcon))
    local  action = CCSequence:createWithTwoActions(CCDelayTime:create(30),secondAction)
    iconTqimage:runAction(action)



可以简单的写成这样:

     local action = CCFadeOut:create(2)

      ImageView:runAction(action)


local action = CCFadeIn:create(2)

    ImageView:runAction(action)


Coco2d-x学习之路

你可能感兴趣的:(Cocos2d-x总结学习)