13 Comments for this entry

  • Lena

    I am a new user of cocos2d. now I am develop card game. but suffer difficulty: when send card, it’s back of the card, and when open card, we should make effect from card back to front.
    can you give me some suggests?

    Thanks a lot!

  • aeonphyxius

    Hi Lena,
    If I understand correctly you want to create an effect kind of “fade in” / “fade out”. Let me suggest you some links:

    1- This is an implementation of fade in / fade out effect with some blinking:
    http://gamedev.stackexchange.com/questions/31235/image-with-fadein-effect-blinks-when-added-to-scene

    2- Some tips about how to flip a card around a corner (Perhaps the same effect you are trying to do):
    http://gamedev.stackexchange.com/questions/53622/how-to-flip-card-by-a-corner

    3- The last one is an advance effect. If you know your way around shaders, perhaps you can try this:
    http://www.raywenderlich.com/10862/how-to-create-cool-effects-with-custom-shaders-in-opengl-es-2-0-and-cocos2d-2-x

    I hope this helps, if you have any further question, please let me know 🙂

  • Mandy

    Thanks for posting this tutorial. I am curious which version of Cocos2d-X you are running and if you are on VS10 or VS12?

  • aeonphyxius

    Hi, thanks for you comment 🙂

    For this post I used VS 2010 and cocos2d-x-2.0.3

    I think that the method spriteWithSpriteFrameName has been deprecated and now you have to use createWithSpriteFrameName

    I might update the tutorial in order to make it compatible with cocos2d-x-2.1.4

  • TheRod

    Hi, thanks for the tutorial,
    Can you tell me what happened with CCPointer?
    I can’t find also the equivalent of “itemWithNormalSprite”

    Thanks again, Rod.

  • aeonphyxius

    Hi Rod,

    CCPointer is an extension for cocos2d-x that you can download from here

    Is a smart pointer to be used with cocos2d-x objects. In case you do not want to use it, you can change the following lines:

    // Our main menu object
    CCPointer <CCMenu> _MainMenu;

    // Each component of our menu (we will reuse them)
    CCPointer <CCMenuitemsprite> _mainMenuButtons;

    by this:

    // Our main menu object
    CCMenu *_MainMenu;

    // Each component of our menu (we will reuse them)
    CCMenuItemSprite *_mainMenuButtons;

    As you can see, you can just use normal pointers and your problem will go away 🙂

    About your other question and the missing function, as i just mention in a another comment above I think the one I have used on this post was from an older version, and is deprecated now:

    I think that the method spriteWithSpriteFrameName has been deprecated and now you have to use createWithSpriteFrameName

    I hope this answers your question,

    aeonphyxius

  • TheRod

    Thanks for your fast response, If i use the pointer like you say, it works, but it crashes in other lines…
    I think cocos2dx has changed a lot to make your code works in the actual version…

    Thanks a lot 🙂

  • aeonphyxius

    Hi Rod,

    I had updated this tutorial to work with cocos2d-x 2.2.3 what is the last 2.x version. The source files also has been updated accordingly.

    As you can see below there are some small changes in the creation process :

    _mainMenuButtons = new CCMenuItemSprite();
    _mainMenuButtons->initWithNormalSprite(
    CCSprite::createWithSpriteFrameName(“bt_play.png”),
    CCSprite::createWithSpriteFrameName(“bt_play_sel.png”),
    NULL,
    this,
    menu_selector(MenuScene::menuCallback));

    I can’t say if this code works with 3.x as the game I am working on is going to be released in the next days and will be released with cocos2d-x 2.2.3

    Also, if you do not manage, just drop me an email with your code and we can have a look together.

  • TheRod

    Now it works pretty nice!

    Thank you so much aeonphyxius!!

    What kind of game are you developping? 🙂

    Could you please tell me, if I want to call a .tmx file, for example by clicking the play button, how should I do to manage the different scenes?

    Something like CCDirector::sharedDirector()->end();

    Thanks again for sharing your knowledges!

  • TheRod

    I used:

    CCScene *hScene = HelloWorld::scene();
    CCDirector::sharedDirector()->replaceScene(hScene);

    to change scene and it works perfect!

Leave a Reply