Add a background objects

This version of the tutorial is deprecated. Please refer to the Platformer Tutorial, Part 1: Getting Started for the completely revised version of the tutorial.

Right now the level is quite simple without the fancy stuff. Let's add some static objects in the background.

Create objects

Adding objects in the background is really easy: just add some sprites with the images you wish and put them on the scene.

For example, create a Sprite object, add an animation and add the bush image:

You can name this object Bush, and also add another object with the cloud image:

Put objects on the scene and change the z-order

If you add objects on the scene, you can see that the player is displayed behind them:

Every instance on the scene has a property which is called z-order. It's a number and objects with a higher Z-order will be displayed in front of objects with a Z-order that is lower. Z-order can be any number, and it can be negative too.

Here, you can change the Z-order of bushes and clouds to set them negative, so that the player character (with a Z-order that should be 1) is displayed in front of them. To do this, select the instances on the scene. You can keep pressing SHIFT on your keyboard to select more than one object:

Then, change the value of the field “Z-order” in the Properties panel on the left. For example, -2 (or any negative number) will ensure that these objects are behind the player:

We now have the visual result that we wanted:

Launch a preview to check that everything is working well!

Next step: add coins and display how many have been collected

Let's add a goal for the player: to collect as many coins as possible! To do this, we're going to use events to remember the player score, play sounds and remove the collected coins!

➡️ Read the next part of the tutorial here!