James Dunay
James Dunay

Reputation: 2724

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?

Upvotes: 1

Views: 6737

Answers (2)

Sivda
Sivda

Reputation: 141

I think tilt should be class of string
And the CCString part should be
CCString::createWithFormat("%s%d.png", tilt.c_str(), i);

Upvotes: 4

Morion
Morion

Reputation: 10860

try this

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

Upvotes: 3

Related Questions