coco 2 dxでリメイク効果を実現
3814 ワード
昨日食事をして同僚が彼の作ったトランプの効果をデモンストレーションするのを見て、感じは悪くなくて、私の心血もやって、とても簡単で直接コードに行きます.
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;
};