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

Rotating the turret


Now we need to make the turret rotate to the green ball. Go to the event sheet, click on Add event, select System, and then select the Every tick event.

Once you have these changes in your event sheet, you can add an action to the turret. Go to the Add action sheet and add the Rotate toward position action.

In the Parameters for Turret window, set the Degrees textbox to 10. This is the speed with which the turret will rotate. You generally want a high rotation speed so that the turret can rotate on time. Remember that the turret does indeed rotate towards the object. It is best to have this speed as fast as possible because if it is too slow, then the turret will not be able to aim and hit the target. In the X textbox, type BallGreen.X and type BallGreen.Y in the Y textbox, as shown in the following screenshot. This rotates the X and Y position of the green ball.

Your project should now look like the following screenshot:

Go ahead and test the game. Add a turret and see whether...