Hey everyone, its been awhile since I've been on the Sparrow boards. I finally have had some free time to get back on my game which has been great.
So I am having a problem stopping an SPTween that I am using as a timer.
I built a LSPSpawnTimer class to manage spawning which is handled through its delegate. The SpawnTimer class has a strong pointer to a SPTween that acts as the timer. It's a random spawn timer so every time the tween completes I recalculate a random time and start it back up with the new random time. I provided code below for you to see.
The problem is, when I stop the timer, onComplete will fire which starts the timer back up. However, if I stop the timer and completely remove the SpawnTimer class from memory the timer will stop. Also note, I was using a NSTimer which stopped fine via invalidate and setting to nil.
-(void)startWithRandomTime
{
//random time calculated here
_timer = [SPTween tweenWithTarget:self time:time];
[Sparrow.juggler addObject:_timer];
__weak LSPSpawnTimer *weakSelf = self;
_timer.onComplete = ^{
if (weakSelf.timer)
[weakSelf handleTimer];
};
}
-(void)handleTimer
{
[self stopTimer];
//random count generated here
[self.delegate spawnTimer:self didSpawnWithSpawnCount:count];
[self startWithRandomTime];
}
-(void)stopTimer
{
printf("\n stop timer");
[Sparrow.juggler removeObjectsWithTarget:self];
[Sparrow.juggler removeObject:_timer];
_timer.onComplete = nil;
_timer = nil;
}
I can't figure out for the life of me why the timer just won't stop, but I'm gonna keep looking.
I am also using latest from Master. And a side note, I am loving MRC! My fps has substantially improved.