Created
October 13, 2012 21:50
-
-
Save syuhari/3886257 to your computer and use it in GitHub Desktop.
flip card for cocos2d-x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Thanks for posting,it works.But i want flip and back flip both,after click..i've edit the above code and make one CCSprite and a CCMenuItemSprite.So i've four functions 2 for flip and 2 for back flip. My problem is i am not getting CCMenuItemSprite at the end..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much for your posting good sample