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?