Backgrounds and tilesets are the two most important asset types in Stencyl when it comes to constructing the ludic (game) and aesthetic aspects of the spaces in our levels. Backgrounds can be used to great effect in providing a fictional context and can assist in creating a sense of depth through the use of effects, such as parallax scrolling, and so on. Tilesets can be used to create a vivid and varied, yet memory-efficient, ludic space within our game levels. In this chapter, we will learn how to:
While the asset type is referred to as a Background in Stencyl, they can be used as either backgrounds or foregrounds within our game levels, which means that we can place them either behind or in front of the active play area of our game. In particular, in the case of platform games, the use of both foregrounds and backgrounds with staggered parallax scrolling speeds can create a real sense of richness and depth in our game worlds.
If the empty game project, we created at the end of Chapter 2, Starting the Game Project, is not open on your computer, please reopen it now. On the Dashboard, on the left-hand pane with the list of available asset types, click on Backgrounds. You should see the following screenshot:
Click on it, and you will be presented with the following window:
Provide a Name for your new background. As a general principle, it is best to be as descriptive as possible at this point so that it is easier to distinguish between our various background assets later on, when we have imported several assets. Perform the following steps:
Grass Background
.This is the Background Editor. To the right, you will see a pane with various parameters that can be used to create parallax scrolling effects. To the left, we have a button that can be used to add new frames to our background. We can add more than one frame if we wish to animate the background, though excessive use of this feature is likely to adversely impact memory and performance, especially on mobile targets. Click on the Add Frame button, and you will be presented with the following window:
From left to right, at the top of the window, the options we are presented with are as follows:
Before clicking on the Choose Image button, we must first ensure that we have selected the correct Scale and Resize Method (or algorithm), and configure a few other settings. Follow these steps:
Game Assets
| Graphics
| Backgrounds
and import Grass Background.png
, as shown in the following screenshot:Click on the Add button at the bottom-right corner of the window, and you will have imported your first static background into Stencyl. Congratulations! Next, we want to configure our parallax scrolling settings for the background:
Now, let's test what we learned so far. Let's repeat the steps we just followed to import the following three background images found in the same Backgrounds directory as the first image we imported:
Well done! We have successfully imported and configured all of the background images needed to build our prototype game. Now we just need to import our first tileset, and we can start building our own 2D game worlds!
3.138.69.163