-1

Really confused here.

NSInteger iteration;
NSInteger direction;

- (void)pulse {
    self.position = ccpAdd(self.position, vectors[iteration]);
    iteration = iteration + direction;
    if (iteration >= totalIterations) {
        direction = -1;
        iteration = totalIterations - 1;
    } else if (iteration < 0) {
        direction = 1;
        iteration = 0;
    }
}

What's happening is once iteration exceeds totalIterations, iteration never goes back below. When the loop comes around again, po iteration shows it as equal to totalIterations.

AFAIK I'm not adding it elsewhere.

Am I missing something? Something to do with NSInteger?

quantumpotato
  • 9,637
  • 14
  • 70
  • 146

1 Answers1

0

Subclass had the same instance variable name as the parent class.. the parent class was incrementing this instance variable.

quantumpotato
  • 9,637
  • 14
  • 70
  • 146