Sprite object

Sprite objects are the most often used objects in GDevelop.

A sprite object allows us to display an image or to play a series of images as animation. A sprite object can be used for many things in our games. Buttons, characters, and platforms are all considered objects. Anything that can be represented with an image can be a sprite object.

How to create a sprite object

In order to add a sprite to your scene, select the “click to add an object” option located on the right at the bottom of the Objects list.

A new panel will open that presents you with a list of options.

Choose “Sprite” from the list to create a new sprite object in your game scene.

Once we have our sprite created, right click the sprite object on the Object list. Select “Edit object” from the popup menu. This selection will open up the object properties window. The properties are different for each type of object. If the object is a sprite, we will see something like this

Add animation

Next, we want to click the add animation button.

Now we should see what a sprite object is all about.

On this screen we add images to our object by clicking on the plus symbol.

Next we need to browse our computer for an image and select one. Once done, the spite image will be displayed in the window.

If we leave the image as is, our sprite object will display a single image when added to our scene. But we can also add additional images to create an animation!

Name the animation

We can also name the animation above so that we can refer to this animation using its name.

If we don't enter a name we need to use the animation number to refer to this animation.

Speed of the animation

We can also set the speed of the animation by changing the value by the clock icon. The value we enter here is basically the elapsed time between each frame. 1 is 1 second but we can enter smaller values too such as 0.5 for example for faster playback.

Repeat the animation

By default every animation plays only once, meaning when the last frame of the animation is finished, it will stop. In some cases, it is preferred to repeat or “loop” the animation. That is done by setting the animation to “loop” by clicking the repeat icon. Once an animation is set to loop, it is going to play continuously.

Add multiple animations

We can also add multiple animations. To add animations, click the “add animation” button in the same way that we did it the first time. This feature allows us to easily separate the different animations.

Later, we can switch between the animations using events.

Finally, to save the sprite properties, click the “Apply” button located on the bottom right corner of the panel.

To add the sprite object to our scene just select it and click in the scene to add an instance of the object to our scene.

Your new sprite is now complete, but you still need to add it to your game scene. Click on the new sprite in the Object list. Next, click on the scene where you want to add the sprite. You will now see your sprite added to the scene. You can add multiple “instances” of your sprite to your game screen. Simply repeat the process for adding the first sprite.

More information on multiple animations while using events

Using events to change animation can be done by creating multiple animations, as explained above, each with their own personal input images. Setting the clock between 0 - 1 will ensure it stays active when using events.

NOTE: Unlike other software, ⇐ -1 disables the event actions. Do not use negative values.

When you have set multiple animations for an object, you can use the events tab to 'set animation by name'. This is controlled in the add action section of the condition. It will allow whatever condition you use in the add condition section, to switch to the correct animation when the event occurs.

NOTE: As a habit, make sure to add a name to your animation using the name section in the objects properties:

Then put that name within the event action with “” around it:

For more event details, follow the tutorials.