Search code examples
iphonec++ioscocos2d-iphonecocos2d-x

formatWithString: Cocos2d-x passing in a CCString


Maybe i'm going about this wrong, and if i am please tell me because i just dont know any better.

But i am trying to pass in a CCString into the following format, and not having any luck. Could someone please tell me what the parameter for strings would be in C++ when passing them into another string?

Code:

CCString tilt = "";

        if (recalculatedFrames >= 4 && (numberOfTimesRun > 0 && numberOfTimesRun < recalculatedFrames - 1)) {
            tilt = "TR_";
        }

        initalTurnAnimationFrames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::stringWithFormat("%s%d.png", tilt, i)));

Also is it fine to make a blank string like i am doing with tilt?


Solution

  • try this

    CCString::stringWithFormat("%s%d.png", tilt.getCString(), i)