Hey All,
So I was wondering what the best way to implement like a gun reload timer is. What i have are three sprites in an array. I also have a plist that has certain settings for each sprite such as reload time. What would be the best way to do this? What im doing right now is in the playerSprite (sprite subclass) i have a BOOL shootReady. then in my touches I have a method that if you touch it will shot if shootReady = YES;. Then once it shoots it makes shootReady = NO;. Then in my main loop i call updateShootStatus, which does the following. It first grabs the reload time varible for each of the characters. it then goes through the array like this:
NSArray * mySprites = [PlayerSprite allPlayerSprites];
PlayerSprite * obj = (PlayerSprite *)[mySprites objectAtIndex:0];
if(obj.shootReady == NO) {
[self schedule: @selector(player1:) interval: player1Wait];
}
PlayerSprite * obj1 = (PlayerSprite *)[mySprites objectAtIndex:1];
if(obj1.shootReady == NO) {
[self schedule: @selector(player2:) interval: player2Wait];
}
PlayerSprite * obj2 = (PlayerSprite *)[mySprites objectAtIndex:0];
if(obj2.shootReady == NO) {
[self schedule: @selector(player3:) interval: player3Wait];
}
Then the tree timers just change shootReady to YES. This method works but it seems like its to complicated for what it has to do. What would be the best way to do this?
Thanks
-Lars