CCTransitionPageTurn(场景切换特效之 ---翻页)

页面翻转过渡效果
本文介绍了一种模拟页面翻转的场景过渡效果实现方法,该方法通过3D动作实现底部右角翻页动画,适用于游戏及应用开发中场景切换的需求,并推荐开启深度缓冲以获得更好的视觉效果。



#ifndef __CCPAGE_TURN_TRANSITION_H__

#define __CCPAGE_TURN_TRANSITION_H__


#include "CCTransition.h"


NS_CC_BEGIN


/**

 * @addtogroup transition

 * @{

 */


/**

@brief A transition which peels back the bottom right hand corner of a scene

to transition to the scene beneath it simulating a page turn.


This uses a 3DAction so it's strongly recommended that depth buffering

is turned on in CCDirector using:


 CCDirector::sharedDirector()->setDepthBufferFormat(kDepthBuffer16);


 @since v0.8.2

*/

class CC_DLL CCTransitionPageTurn : public CCTransitionScene

{

protected:

    bool    m_bBack;

    

public:

    CCTransitionPageTurn();

    virtual ~CCTransitionPageTurn();


    /**

    * Creates a base transition with duration and incoming scene.

    * If back is true then the effect is reversed to appear as if the incoming 

    * scene is being turned from left over the outgoing scene.

    */

    static CCTransitionPageTurn* create(float t,CCScene* scene,bool backwards);


    /**

    * Creates a base transition with duration and incoming scene.

    * If back is true then the effect is reversed to appear as if the incoming 

    * scene is being turned from left over the outgoing scene.

    */

    virtual bool initWithDuration(float t,CCScene* scene,bool backwards);


    CCActionInterval* actionWithSize(const CCSize& vector);


    virtual void onEnter();

{

    CCTransitionScene::onEnter();

    CCSize s = CCDirector::sharedDirector()->getWinSize();

    int x,y;

    if (s.width > s.height)

    {

        x=16;

        y=12;

    }

    else

    {

        x=12;

        y=16;

    }


    CCActionInterval *action  = this->actionWithSize(CCSizeMake(x,y));


    if (! m_bBack )

    {

        m_pOutScene->runAction

        (

            CCSequence::create

            (

                action,

                CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),

                CCStopGrid::create(),

                NULL

            )

        );

    }

    else

    {

        // to prevent initial flicker

        m_pInScene->setVisible(false);

        m_pInScene->runAction

        (

            CCSequence::create

            (

                CCShow::create(),

                action,

                CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),

                CCStopGrid::create(),

                NULL

            )

        );

    }

}

protected:

    virtual void sceneOrder();

};


// end of transition group

/// @}


NS_CC_END


#endif // __CCPAGE_TURN_TRANSITION_H__


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值