dynamically change image of sprite (from sprite sheet)

  • abhishek
    Likes 0

    Problem Description

    i used this line of code in cocos2d-x v2.2 to dynamically change image of a sprite, the image was saved in sprite sheet:

    sp_baby1->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(ccsf("baby4_happy_%d.png",baby1)));

    but now i am using cocos2d-x v3.0 and this line does not work anymore.
    i want to be able to change the image of a sprite dynamically. and the images are in a sprite sheet.
    for example: baby_1 to baby_10
    now depending upon the value of myInt (could be between 1 to 10), i want to set the image of my sprite.
    how can i do this?
    could you please help?
    thanks

  • Sonar Systems admin
    Likes 0

    See other post for reply.

Login to reply