"weird" Render stringWithFormat run-time error that crash the app.

Discussion in 'iOS Programming' started by PizzaTray, Nov 16, 2009.

  1. PizzaTray macrumors newbie

    Oct 31, 2009
    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.

    int [COLOR="Red"]scoreInt[/COLOR];
    NSString *[COLOR="red"]scoreTxt[/COLOR];
    float timerFloat;
    NSString *timerTxt;
    If detects collision:
    if(enmy1.isAlive) {		
    enmy1.isAlive = NO;
    [COLOR="red"]scoreInt[/COLOR] += 10;
    [COLOR="red"]scoreTxt[/COLOR] = [NSString stringWithFormat:@"%d", [COLOR="red"]scoreInt[/COLOR]];
    Render it:
    [fontScore drawStringAt:CGPointMake(20,0) [COLOR="red"][COLOR="Black"]text:[/COLOR]scoreTxt[/COLOR]];
    [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, if someone wants.
  2. AndyCodez macrumors regular

    Aug 6, 2009

Share This Page