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 cannon


Now, we are ready to make our game. Let's go to the event sheet and add an Every Tick event by navigating to System | Every Tick. Once you have added that, add an action. In this case, it's going to be for the cannon sprite and the action should be Rotate toward position. Check the following screenshot:

We are going to rotate the cannon with the mouse. Luckily, this is really easy to do in Construct 2.

Let's move the cannon by 10 degrees (this is the speed at which the cannon rotates). In the X box, type mouse.x and type mouse.y in the Y box. This will rotate the cannon to the position of Mouse.X and Mouse.Y, or simply the mouse position. This is shown in the following screenshot:

Run the game and test it out. It is good to test early and often. Make sure you save often as well. You will notice that the cannon does not rotate the way we want it to—the reason is that the cannon rotates around Origin. Let's double-click on the cannon and move Origin closer to the back of the...