coco2dx实现翻拍效果

昨天吃饭看见同事演示他做的翻牌效果,感觉不错,我心血来潮也来搞个,很简单直接上代码。

coco2dx实现翻拍效果
class FlipCard : public CCNode
{
public:

    CREATE_FUNC(FlipCard);

    virtual bool init()
    {
        if (CCNode::init())
        {
            m_pFront = CCNode::create();
            m_pBack =CCNode::create();
            m_pBack->setVisible(false);
            addChild(m_pBack);
            addChild(m_pFront);
            m_fDeltaFlipAngle = 0.0f;
            return true;
        }
        return false;
    }

    void Flip()
    {
        if (m_pFront->numberOfRunningActions()>0 || m_pBack->numberOfRunningActions()>0)
        {
            return;
        }
        static const float fDuration = 2.0f;

    auto* pSeq1 = CCSequence::create( CCOrbitCamera::create(fDuration*0.5f, 1, 0, m_fDeltaFlipAngle, 90, 0, 0),
        CCHide::create(),
        NULL);
    m_fDeltaFlipAngle+=90.0f;
    auto* pSeq2 = CCSequence::create( CCDelayTime::create(fDuration*0.5f),
        CCShow::create(),
        CCOrbitCamera::create(fDuration*0.5f, 1, 0, m_fDeltaFlipAngle, 90, 0, 0),
        NULL);
    m_fDeltaFlipAngle+=90.0f;
        m_pFront->runAction(pSeq1);
        m_pBack->runAction(pSeq2);

        auto p = m_pFront;
        m_pFront = m_pBack;
        m_pBack = p;
    }

    CCNode* m_pFront;
    CCNode* m_pBack;
    float    m_fDeltaFlipAngle;
};
coco2dx实现翻拍效果

coco2dx实现翻拍效果

上一篇:每天爱你多一点


下一篇:利用apifox来测试API