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

Adding mouse controls


Let's add some mouse controls. First click on Add event and then click on System. The mouse controls will allow us to use the mouse and access its properties, such as position, clicks, and movement.

Then, click on Every tick. The Every tick option will access the game loop and it will make sure that the logic for this event will always be checked.

Once you have Every tick selected, it should look like this:

Click on Add action and then click on the player. Then, select Set angle toward position from the Angle list, as shown in the following screenshot:

As shown in the following screenshot, type Mouse.X in the X box and type Mouse.Y in the Y box. Then, click on Done. This will make sure that the angle of the player will constantly be set to the mouse location. In 2D game development, we need to have two coordinates in order to find a position. These coordinates are X and Y. In order to find the position of the mouse, we need Mouse.X and Mouse.Y, which are the mouse's X and...