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

Discussion in 'iPhone/iPad Programming' started by PizzaTray, Nov 16, 2009.

  1. macrumors newbie

    Joined:
    Oct 31, 2009
    #1
    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:
    Code:
    int [COLOR="Red"]scoreInt[/COLOR];
    NSString *[COLOR="red"]scoreTxt[/COLOR];
    
    float timerFloat;
    NSString *timerTxt;
    If detects collision:
    Code:
    if(enmy1.isAlive) {		
    enmy1.isAlive = NO;
    
    [COLOR="red"]scoreInt[/COLOR] += 10;
    [COLOR="red"]scoreTxt[/COLOR] = [NSString stringWithFormat:@"%d", [COLOR="red"]scoreInt[/COLOR]];
    Render it:
    Code:
    [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!
    Code:
    timerFloat += delta;
    timerTxt = [NSString stringWithFormat:@"%g", timerFloat];
    Any ideas?

    Edit: Someone from other forum solve that for me.
    here, if someone wants.
     
  2. macrumors regular

    Joined:
    Aug 6, 2009
    #2
    Edit: saw the edit
     

Share This Page