Level: Beginner
Atlases
Contents
-
Introduction
-
Atlas Size
-
What can be included inside an atlas?
-
Managing Atlases
-
Assigning Graphics to an Atlas
-
Reducing Memory Usage
-
Atlases and iPad (Stencyl 2.2 and below)
-
Tips
Introduction
Games made for use with mobile devices use atlases to store graphical game assets. An atlas is a large image that combines lots of smaller images into a single unit. Atlases are also sometimes called sprite sheets.

We use atlases to optimize a game's performance and make it possible to use more graphics within a game than a device can load in before exceeding its memory limit, by allowing sets of graphics to be unloaded when they're not in use.
Atlas Size
Important Note: In Stencyl 3.0 and above, atlases are not subject to the atlas size limit, but they still take up the same amount of memory.
Atlases can be up to 4096 x 4096 pixels in size on an iPad Gen 3, 2048 x 2048 on an iPhone 4 / iPad 1/2 / iPod Touch Gen 4 and 1024 x 1024 on everything else (including Android).
For the most part, a game can accommodate 4 to 5 full-size atlases at a time before you’ll see a memory warning.
The most problematic device is the iPod 4, which supports retina but has the least amount of memory (128 MB vs. 256 MB) of all modern devices.
Game Assets that can be included inside an Atlas
-
Actors
-
Fonts
-
Tilesets
-
Backgrounds
-
Animations (within Actors) (Stencyl 2.2 and below)
Managing Atlases
Note: In Stencyl 3.0, atlases can be created and deleted at will.
Every game made with Stencyl 2.2 comes with a pre-set number of atlases defined, which is currently 32. You will never need to "create" an atlas.
The Atlas Page is part of the Settings dialog. Click the Settings button to open the dialog.

Next, click the Atlases button, as shown below. This is where you can configure atlas settings.

Following is a list of the options you can configure for each atlas:
-
Name: The name of the atlas.
-
Load initially?: Whether or not to load the given atlas when the game starts. Loading it at the game’s start will require more memory.
The following options are available in Stencyl 2.2 and below. In Stencyl 3.0, atlases are considerably simpler and do not require such options.
-
Resize Method: This option resizes your graphics to fit the display of a given device.
-
Target Device: The device you intend people to play your game on.
-
Preview: Clicking this option will show you a preview of the graphics in the atlas so you can see how the various options affect your graphics’ appearance.
Assigning Graphics to an Atlas
To assign a tileset, actors, fonts, or backgrounds to an atlas, visit the Properties page for that resource, click on the Atlas dropdown menu and select which file you would like to assign to a given atlas.

Reducing Memory Usage
You can load and unload entire atlases during the game to minimize memory usage. Stencyl can also unload atlases from the get go, and only load them when they are needed, to reduce memory usage.
You can use the “load/unload atlas” block to do this at runtime. This block is located under Flow > Advanced.

When you use this block, Stencyl will load and unload the specified atlases for the NEXT scene (NOT the current scene). You specify the atlas to load/unload by its ID. A given atlas’ ID is displayed in the atlas' own page.

Using Atlases With the iPad (Stencyl 2.2 and below)
Note: In Stencyl 3.0, none of the directions below apply because we automatically handle iPad vs. iPod graphics loading separately, so you never run into a scenario where both sets of graphics are loaded at the same time.
One approach to creating a universal game (one that runs on iPhone and iPad) is to create two sets of graphics. However, this can strain memory usage if both sets of graphics are loaded, even if one set won’t be used at all when the game is played on one device vs. another!

(Both iPhone and iPad graphics in one atlas - not optimal)
To work around this issue, assign iPad-only graphics to particular atlases and mark those atlases as iPad only.

If you're designing your game such that you’re including iPad graphics, in addition to other graphics, for an actor via different animations, there is a dropdown to assign a different atlas on a per-animation basis.
In this case, the game author created a Button in which different animations are used depending on whether the game is played on an iPhone or iPad.
Tips for Using Atlases
-
Keep the most common graphics in the Main Atlas.
-
Combine graphics that tend to appear together as much as possible, so they are located in the same atlas.
-
Use the Allocations feature in Xcode’s Instruments tool to monitor memory usage if you receive memory warnings.
-
Don't load more atlases than you need! Using atlases intelligently can reduce memory usage and improve your game’s load time.
Last Updated: 2013-04-13 by Ceric
11801 have read this article
Disclaimer: The Stencyl Team does not actively monitor comments on articles. If you're seeking help for your game,
please ask a question on the forums. Thanks!
Sign In to Comment