Time for action – launching stones
It doesn't take too much time to win our game right now. Just take one step to the left or right and the stone will fall without hitting the hunter. If this is the punishment for shooting birds, then our hunter isn't going to learn anything.
It is time to throw more stones and make them fall at different places to make the hunter run around the level to avoid being hit by stones. Perform the following steps:
- Open the
PhysicsScene.m
file, add_timeUntilNextStone
, and add the_stones
array instance variables, as shown in the following code:@implementation PhysicsScene { //..skipped.. float _timeUntilNextStone; NSMutableArray *_stones; }
- Add the following code to initialize the array and the time counter in the
onEnter
method, right below the[super onEnter];
line:-(void)onEnter { [super onEnter]; _stones = [NSMutableArray array]; _timeUntilNextStone = 2.0f; //..skipped.. }
- Then, add the
fixedUpdate:
method with the...