tags:

views:

32

answers:

1

I have a timer set up and it gets called when ever the player is in their turn phase. I also have a multiplier that decrements slowly while the player is committing actions.

for some odd reason my mult variable is returning garbage values I initialized it to 1 in the onLoad statement but it still seems to have trouble. each time the Timer fired off the value would immediately show up in the NsLog statement as a really large negative number. when ever I gained points it would turn into a really large positive number.

-(void) Timerbar:(NSTimer *)barTimer {


 if(!waitForPlayer) {

  [barTimer invalidate];

 }
 if(mult > 0.0) {
  mult -= 0.01;
  if(mult < 0) { 
   mult = 0;
  }
 } 
 power =  (mult * 10) / pwrBarMaxWidth;
 pwrBarWidth = (int)power  % limit;
 NSLog(@"%d", mult);
}

Do I have a syntax error somewhere?

edit- turns out that I used the wrong identifier to display the float.

+4  A: 

Assuming that mult is a float or double, then you are using NSLog's print format incorrectly. You want

NSLog(@"%f", mult);

Here's a great reference:

http://www.cocoadev.com/index.pl?NSLog

Typeoneerror
Good catch ! Considering the vagueness of the question..
tomdemuyt
Yeah, that was great! i'm sorry if my question was a bit vauge. That worked spot on.
Ohmnastrum