39,561

Views

Beginner

Level

4

Comments

Scene Basics

by Jon (Updated on 2014-01-26)


Scenes are a game’s “worlds” or “levels.” Scenes are where everything in a game takes place. This article talks about the fundamental concepts of Scenes.

Looking instead for a guide on *how* to use our Scene Designer? You can find it here.


Contents

  • Scenes and Game Flow
  • Tiles
  • Layers
  • Coordinates
  • Boundaries

 

Scenes Control a Game’s Flow

Think about a game such as Super Mario Bros. When you play through the first level and reach the flagpole at the end, there’s a brief victory sequence, and then Mario proceeds to the next level.

Sometimes, scenes aren’t levels at all. Even a main menu itself can be a scene.

Putting this together, scenes can be thought of as various states in a game that you transition between, like a story.

Switching scenes is described later in this chapter, but in a gist, use the following blocks to switch scenes. (Scene > Game Flow).

Switching scenes involves an "outgoing" transition (such as a fade out), the scene you are switching to, and then an "incoming" transition (such as a fade in).


Tiles

What are the building blocks of a scene? The scene’s terrain or “land” is typically made up of Tiles.

Much like the tiles on your kitchen counter or bathroom, Tiles in a game are uniformly sized pieces of land that conform to a grid. That is to say...

  • Every tile is the same size.
  • Tiles are spaced equally apart - by the tile size.

Why are tiles a great way to build levels? Imagine that you’re building a sophisticated action game such as Super Metroid.

It would be impractical to create separate sprites for each land mass. After a while, you’d run out of space trying to pre-render all of that!

Tiles are a cheap, reusable way of creating worlds. You’ll find that with tiles, virtually any kind of land form can be re-created with ease. Using this tileset...

We can make a rich landscape out of this.

Tiles need not be square. You can define tiles as triangles and any kind of convex polygon in order to support slopes and other complex forms of terrain.

What if you’re building a game where tiles are inappropriate, as pictured below? You’re able to define custom terrain to satisfy this use case.

(Not a tile-based game, use the Custom Terrain tool!)


Importing Tilesets

For information on how to import tiles and work with our Tile Editor, read our article on that.


Layers

What if you want some parts of the scene to draw on top of other parts? For example, you may want a guarantee that the player draws in FRONT of the game’s scenery.

A Layer is a group of both Actors and Tiles that are drawn at the same time. In this way, Layers provide you a flexible yet simple way to determine what order things are drawn in.

To take the example above, here’s the breakdown of what’s on which layer.

Scenes can have an arbitrary number of layers. There’s no limit and no performance hit to having more layers as opposed to fewer.

Managing Layers

Use the Layers Pane inside the Scene Designer to manage layers. You can create, remove, rename and re-arrange layers using this interface.


Switching Layers

Sometimes, you’ll want to change what layer an Actor is on. To do this, use the following blocks. (Actor > Draw)

When sending an Actor to a particular layer, specify the Layer’s ID. You can find this inside the Layers Pane inside the Scene Designer. In the future, we’ll let you specify a Layer’s name instead.


Coordinates

Every element inside a Scene has a position. This position consists of an X (horizontal) and Y (vertical) component and corresponds to the top left corner of that element.

(0,0) is the top left most point in the scene.


A higher X value moves you towards the right, while a higher Y value moves you towards the bottom.

 

Boundaries

Every scene has boundaries (a size) that you define when you first create the scene. These boundaries control how far the Camera can travel and how far Tiles can extend.

Although actors can go beyond a scene’s boundaries, actors that are not designated as always active will “freeze” upon doing this.

Imagine boundaries to be like the limits of a level in Mario

Going beyond certain bounds is either not permitted (left & right) or leads to death (off the bottom).


Summary

  • Scenes control the flow of a game, like a storyboard.
  • Tiles are equal-sized building blocks. They define the terrain.
  • Layers group together tiles & actors in order to control drawing order.
  • (0,0) is top left in our coordinate system.
  • Scenes have boundaries (a size) that define how far actors and terrain can be placed.
Disclaimer: All articles are geared towards Stencyl 3.0 and above. Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!

4 Comments

jgcthatsme
Is it common or uncommon to have an animated background with 480 frames? Can I even do that? This is for an OSX game (not mobile). And if not, is there a way to import an image sequence as my background. It isn't created to loop, so once it gets to 480th frame, thats it...... Please advise. Thanks.
0 5 months, 2 weeks ago
Stencyller
Cant fined the color dropdown

0 9 months, 3 weeks ago
maddy
ya its good!!
0 2 years, 2 months ago
purewater156
okay, get it... it sounds complicated, though.
0 2 years, 3 months ago

Sign In to Comment