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 physics


Run the game again and you will see that the cannonball does not act like a cannonball. We need to add some physics to it! Click on the cannonball and add the Physics behavior as shown in the following screenshot:

Applying force at an angle

Run the game again.

You will notice that the ball just falls down! Now that we have added physics, we can add a force to the cannonball to make it shoot like real cannon. Add an action to the Mouse click event. The action will be Apply force at angle, as shown in the following screenshot:

Set the force to around 200. The bigger the number, the further the cannonball travels. For the angle, type in cannon.Angle as shown in the following screenshot. This will ensure that the cannonball is shot in the same direction as the cannon.

Setting cannonballs to fire one at a time

If you run the game, you will notice that we can fire as many cannonballs as we want. We should limit the cannonballs to make them fire only one at a time. In order to do this...