I have a ship and I want to make it to shoot every 1 sec. So here's what I did,
@property (nonatomic, assign) float lastDamageTime;
and in the update method,
if (CACurrentMediaTime - self.lastDamageTime > 1)
{
self.lastDamageTime = CACurrentMediaTime;
[self shoot];
}
But the problem is, say I pause the game right after the ship shoot a bullet, and then 1 sec later, I resume the game, the if statement pass the check, and the ship will shoot another bullet immediately. And that's not what I want.
So, what can I do to make sure the ship fire bullets each sec weather I pause the game or not? Should I use CCTimer instead?
Thank you in advance for your answer.