PDA

View Full Version : "weird" Render stringWithFormat run-time error that crash the app.




PizzaTray
Nov 16, 2009, 10:16 AM
I'm trying to render to screen the score of the player in my game.
The problem is that after he kills first enemy, the score(Int) going crazy with numbers and after few seconds its crash the app.

The thing is, that i'm rendering to screen the time(float) that passed too, and it works great.

Define:

int scoreInt;
NSString *scoreTxt;

float timerFloat;
NSString *timerTxt;
If detects collision:

if(enmy1.isAlive) {
enmy1.isAlive = NO;

scoreInt += 10;
scoreTxt = [NSString stringWithFormat:@"%d", scoreInt];
Render it:

[fontScore drawStringAt:CGPointMake(20,0) text:scoreTxt];
[fontTimer drawStringAt:CGPointMake(380,0) text:timerTxt];

And the same thing here, BUT its NOT crashing my app!

timerFloat += delta;
timerTxt = [NSString stringWithFormat:@"%g", timerFloat];

Any ideas?

Edit: Someone from other forum solve that for me.
here (http://www.iphonedevsdk.com/forum/iphone-sdk-game-development/33597-weird-render-stringwithformat-run-time-error-crash-app.html#post142932), if someone wants.



AndyCodez
Nov 16, 2009, 12:34 PM
Edit: saw the edit