Game Development Reference
In-Depth Information
Firing the turret
Now that the turret rotates, we can go ahead and add a projectile. Go and add another
event. This time, it will be set to Every X seconds .
After you have added this event, add an action. This time, it will be for the turret. Select
Spawn another object .
The object that we want to spawn is Projectile , as shown in the following screenshot. We
want to spawn it on layer 1, where we have spawned all the rest of our game objects (ex-
cept the background) so far.
Go ahead and run your game; it should work out pretty well. You will notice that the turret
offscreen keeps firing. One thing that we need to do is add a Destroy outside layout beha-
vior. We cannot just delete the offscreen sprite, as we need to have a reference for when we
want to add more sprites. Sometimes, if you delete all of the instances of a sprite, the game
will crash. So, add the behavior for the turret, as shown in the following screenshot:
Go back to your event sheet and add an event. This event will check whether the projectile
hits the green ball. Select Add event and select the projectile. Then, select On collision
with another object .
Search WWH ::




Custom Search