Skip to content

Instantly share code, notes, and snippets.

@dabing1022
Forked from syuhari/CardFlip
Created November 21, 2013 15:09
Show Gist options
  • Save dabing1022/7583209 to your computer and use it in GitHub Desktop.
Save dabing1022/7583209 to your computer and use it in GitHub Desktop.
void Card::flipAction() {
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* card = CCSprite::spriteWithFile("card_face.png");
card->setPosition(ccp(winSize.width/2, winSize.height/2));
this->addChild(card, CARD_FACE_TAG, CARD_FACE_TAG);
card->setVisible(false);
CCSprite* card2 = CCSprite::spriteWithFile("card.png");
card2->setPosition(card->getPosition());
this->addChild(card2, CARD_BACK_TAG, CARD_BACK_TAG);
CCOrbitCamera* camera = CCOrbitCamera::actionWithDuration(FLIP_DURATION/2.0f, 1, 0, 0.0f, 90.0f, 0, 0);
CCHide* hide = CCHide::action();
CCCallFunc* func = CCCallFunc::actionWithTarget(this, callfunc_selector(Card::flipAction2));
CCActionInterval* action = (CCActionInterval*)CCSequence::actions(camera, hide, func, NULL);
card2->runAction(action);
}
void Card::flipAction2() {
CCSprite* card = (CCSprite*)this->getChildByTag(CARD_FACE_TAG);
CCShow* show = CCShow::action();
CCOrbitCamera* camera = CCOrbitCamera::actionWithDuration(FLIP_DURATION/2.0f, 1, 0, 270.0f, 90.0f, 0, 0);
CCActionInterval* action = (CCActionInterval*)CCSequence::actions(show, camera, NULL);
card->runAction(action);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment