Book Image

Construct 2 Game Development by Example

By : John Bura
Book Image

Construct 2 Game Development by Example

By: John Bura

Overview of this book

Table of Contents (16 chapters)
Construct 2 Game Development by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Where to Go from Here
Index

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 (except 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 behavior. 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...