Optimizing Performance (Mobile)
by Jon (Updated on 2014-01-30)
- Tip #1 - Don't use too many layers.
- Tip #2 - Don't use too many actors.
- Tip #3 - Load in just the atlases you need.
- Tip #4 - Performance only matters on the actual device.
- Tip #5 - Watch your memory usage.
Performance is an important consideration for your game. It dictates how smoothly the graphics display on the actual device. This directly affects a user’s perception of your game.
You should always strive to hit 60 frames per second (FPS) with your game. A well-implemented game can hit 60 FPS, even on older devices (from 2-3 years back).
Although mobile devices are more powerful than in years past, they are still more sensitive to factors that affect performance than PCs are. For this reason, you need to monitor game performance carefully throughout the development process.
Tip #1 - Don't use too many layers.
Although mobile devices now have decent graphics capabilities, they can falter when drawing over the entire screen a few too many times.
To avoid this fate, use fewer layers rather than more. A good rule of thumb is to stick to at most 3-5 layers for your scenes. The fewer, the better.
Be mindful of the platform you’re developing the game for and focus first and foremost on making the base of your game work before making it pretty.
Tip #2 - Don't use too many actors.
Stencyl is based on Box2D, an industry standard physics engine, in order to provide easy, out-of-the-box collisions. The numerous calculations required to run it can be taxing, so it's best to use fewer actors rather than more. There's no hard number which is "bad" since this can vary widely depending on the device and the game.
A related tip is to use Lightweight Actors (or turn on Simple Physics). Lightweight Actors are actors that do not make use of the physics engine, which improves performance. They’re typically non-interactive objects and decorations. Switching over to lightweight actors can increase performance on games with many of these decorative actors, or in games with high actor counts but no physics-requirements, such as puzzle games.
To designate an actor as lightweight, visit its Physics > Advanced page and flip the Disable Physics setting to Yes.
Tip #3 - Don’t load in all atlases at once - use only what you need.
Stencyl stores its graphics inside atlases, composite images that combine many graphics into a single image.
By default, Stencyl loads every atlas at the start of the game. If you don’t need all of those graphics right away, this can be wasteful since those graphics sit in memory, and high memory usage can degrade performance.
Instead, it’s better to only load what you need and load graphics only when they are required.
Tip #4 - Performance only matters on the actual device.
Although the iOS Simulator is an effective and efficient way to test your game, when testing for performance, you should frequently test it on an actual device.
Like its name suggests, the iOS Simulator is simply a simulation of what happens in the game. Your computer is likely to provide significantly better performance than your device, though, so it will usually run the game faster than the real thing.
The same principles apply to Android. You may own a (insert-top-of-the-line-device-here), but you should test your games on devices 2-3 years back to ensure that they run smoothly.
Tip #5 - Watch your memory usage.
As described in our Mobile Debugging article, memory leaks can impact your game's performance over time. Although memory usage in itself does not affect performance, beyond a critical point, a device will see a huge dropoff which can reached if memory usage grows unbounded over time.
Share your tips.
Add a comment below and share your findings.