Let's add some level design. Go to the right area of the layout and add some blocks. As you can see in the following screenshot, we've placed them with a gap between each other. They will fall down; but sometimes if you start a game with an object too close to another, the collision detection can malfunction.
Try out the game. You will notice that the cannonball does not really have a big impact on the blocks. Select them all and change Density to 0.2
, or you can change it to whatever value you want. This is shown in the following screenshot:
Now, we need to add the goalBall
sprites. First, add a Physics behavior to the goalBall
sprite, as shown in the following screenshot:
Next, add more balls to the level and then add an event to the goalBall
sprite:
When the
goalBall
sprite touches the ground, we will destroy it, as well as set up some extra functionality.
Add an On collision with another object action that checks to see whether the goalBall
sprite collides with the transparent Ground object. This is shown in the following screenshot:
When the
goalBall
sprite touches the Ground object, add an action that will destroy the ball. This is shown in the following screenshot:
Once you have done this, copy the action by selecting the event and pressing Ctrl + C and then press Ctrl + V to paste.
Then, for one of the two actions, change the On collision with Ground to On collision with cannonBall, as shown in the following screenshot. This will destroy the goalBall
sprite when the cannonball hits it.
Let's add some particles to make it look better. Go back to the layout, click on Insert New Object, and add Particles, as shown in the following screenshot:
When you add a particle emitter, you add an object that spawns lots of two-dimensional images. They are used for things such as explosions, engines, and anything that looks flashy. Double-click on the particles and add a graphic.
Move the particle to the screen and run the game. We want more of an explosion than the way the particles are currently set up.
Play around with the settings. We suggest changing Spray cone to 360
, Speed randomizer to 20
and Size randomizer to 20
as well. Also, make sure you change Type to One-shot
. This will make the particles only fire once.
Go back to the event sheet and add an action to the goalBall
sprite's On collision with ground. Add a Spawn another object parameter to goalBall
. Make sure it is spawned at the Layer point value 1
, as shown in the following screenshot:
Copy-and-paste this action to the other collision object On collision with cannonBall so that there is a particle explosion when the cannonball hits an object. Then, copy the collision object, but change it so that it is activated when this goalBall
collides with another goalBall
sprite. Check the following screenshot:
18.216.44.143