Creating a cannonball

We need to create a cannonball to fire at the other game objects. Hence, we will create and add in a projectile—a cannonball—for the cannon to fire. Add a On any click event by navigating to Mouse | On any click.

Creating a cannonball

Then, add a Spawn another object action on the cannon, as shown in the following screenshot. We are going to spawn the cannonball when we click the mouse button.

Creating a cannonball

The object is, of course, going to be the cannonball.

Tip

This is where naming your game objects clearly really makes a difference—particularly if you have more than 200 game objects.

Spawning the cannonball

In order to make the cannonball actually "fire", we need to spawn the cannonball first. Set the cannonBall object to spawn on Layer with the value 1 at Image point with the value 1. This is shown in the following screenshot:

Spawning the cannonball

Creating the spawning image point

But wait! We still have to set up an Image point 1! Double-click on the cannon and add an image point by pressing the plus (+) sign. Put the image point next to the front of the cannon, as shown in the following screenshot. The image point is where the cannonball will spawn from.

Creating the spawning image point
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.105.159