Time for action – animating the shooting and limiting the shooting rate
We will continue to add states to the game objects, and this time, we will update the Hunter
class. We're going to animate the process of reloading the arrow and will limit the shooting rate. Let's do this using the following steps:
Open the
Hunter.h
file and addHunterState enum
right after the last#import
directive:typedef enum HunterState { HunterStateIdle, HunterStateAiming, HunterStateReloading } HunterState;
Then, add a property called
hunterState
to theHunter
class as follows:@property (nonatomic, assign) HunterState hunterState;
Add a declaration of the method called
getReadyToShootAgain
using the following line of code:-(void)getReadyToShootAgain;
Switch to the
Hunter.m
file and import theCCAnimation.h
header as follows:#import "CCAnimation.h"
Then, initialize the hunter state to the
HunterStateIdle
state inside theif
block in theinit
method as follows:self.hunterState = HunterStateIdle;
Scroll down...