Username or E-mail
Password (Forgot?)
New? Sign Up
Join or Sign In
Forums Stencylpedia Stencyl TV Translations Go Pro - Plans & Pricing Download Stencyl


Switch to Book Layout

1: Getting Started

  • Getting Started
  • Crash Course
  • Crash Course 2
  • StencylForge

2: Building Logic

  • What is a Behavior?
  • Creating a Behavior
  • Attributes
  • Game Attributes
  • Attribute Types
  • Events
  • Our Behaviors

3: Actors

  • What are Actors?
  • Animations
  • Motion & Forces
  • Physics
  • Controls
  • Collisions & Groups
  • Killing vs. Recycling
  • Tweening
  • Effects
  • Chapter 3 Challenge

4: Scenes

  • Scene Basics
  • The Camera
  • Tilesets
  • Regions
  • Drawing Text & HUDs
  • Changing Scenes
  • Music, Sounds & Channels
  • Backgrounds
  • Customizing Actors
  • Chapter 4 Challenge

5: Game Mechanics

  • Saving
  • Pausing
  • 3rd Party Services
  • Web Requests

6: Advanced Topics

  • Get/Set Attributes
  • Custom Events
  • Blending Modes
  • Lists
  • Custom Blocks
  • Continuous Collisions

7: Testing & Tuning

  • Testing Games
  • Optimizing Performance 1
  • Optimizing Performance 2

8: The Last 10%

  • Flash Publishing
  • Standalone Apps
  • iOS App Store
  • Chrome Store
  • Making Money

M1: Mobile - Intro

  • Getting Started
  • Testing on your Device
  • Flash -> iOS Guide

M2: Mobile - Basics

  • Atlases
  • Drawing Text
  • Retina Display
  • Accelerometer
  • Joystick
  • Universal Games

M3: Mobile - Services

  • iAds
  • Game Center
  • In-App Purchases

M4: Mobile - Publishing

  • Debugging
  • Publishing to the App Store
  • Optimizing Performance
  • Promoting your Game

A: Troubleshooting

  • Showstoppers
  • General FAQ
  • iOS FAQ
  • The 90% Memory Warning
  • Recovering Broken Games
  • Can't Export to SWF
  • Reloading Documents
  • Generating Logs
  • Flash Security Settings
  • How to Report Bugs

B: How-To Guides

  • Importing Assets
  • Scene Designer
  • Code Mode
  • Font Editor
  • Pencyl (Image Editor)
  • Tile Editor (Shapes)
  • Game Cleaner

C: Reference

  • Glossary
  • Block Reference
  • Useful Shortcuts
  • Stencyl API

D: Resources

  • Stencyl TV
  • Abigayl's Guides
  • Giving Critiques
  • Creating Extensions
  • Translating Stencyl
  • Credits

3.0 Drafts (In Progress)

  • What's New in Stencyl 3.0?
  • Setup (Android)
  • Setup (Desktop)
  • Setup (iOS) - Concepts
  • Setup (iOS) - Mac
  • Setup (iOS) - Windows
  • Testing iOS on Windows
  • iOS Troubleshooter

  • Mobile App Scaling
  • Full Screen Mode
  • Simple Physics
  • Backgrounding an App

  • iOS App Store
  • Mac App Store
  • Windows Store
  • Google Play
  • HTML5

  • Android Ads
  • Android Purchases (WIP)
  • 4" Form Factor (iPhone 5)
  • Mobile Input
  • Mobile Features

  • Extending the Engine
  • iOS / Android Extensions
  • Developing the Official Extensions
  • Developing the Engine

  • iAds (Revised)
  • Game Center (Revised)
  • iOS Purchases (Revised)
  • Atlases (Revised)
  • Drawing Text (Revised)
  • Joystick (Revised)
  • Accelerometer (Revised)
  • Sounds (Revised, WIP)
  • Debugging (Revised, WIP)
  • iOS Performance (Revised)
Level: Beginner

Optimizing Game Performance

Part of game development is creating logic that not only works but is optimized for fast, smooth gameplay that meets or exceeds the 60 frames per second mark. In Stencyl, there are many ways to improve your game's performance.

 

Contents

  • Avoid Too Many Collisions
  • Remove Print Statements
  • Limit use of "Make [actor] Always Active"
  • Limit number of on screen actors
  • Avoid expensive per-frame calculations
  • Use Effects in moderation
  • Use Custom Drawing in moderation
  • Avoid drawing over the same spot many times

 

Avoid Too Many Collisions at Once

Stencyl uses Box2D for its physics engine, and the more Stencyl makes use of Box2D, the more calculations it's performing in a given frame. Since collisions means the physics engine is working, more collisions means potential slowdown.

 

To avoid this, make sure the actors that are capable of colliding have something to do with the gameplay you're going for.

For example, unless you want bullets in your game to act like actual bullets, you can safely change their physics settings so they don't make more than basic use of Box2D when they collide with actors.

You can change the physics settings on the Physics > General page for an Actor.

Notice how we've set the collision style to "Cannot be pushed" and disabled both gravity and rotations.

 

Remove Print Statements Before Publishing

If you're using print statements in your game for debugging purposes, you need to remove these before publishing your game. Even when testing, having multiple print statements can really drag down your game's performance.

(Note: In Stencyl 3.0 and above, printing in published games is automatically suppressed.)

 

Limit How Often Actors Use Always Active / Simulate

Although it's often helpful for actors to function while off screen (which is what Always Active allows), consider when you really need to do this in your game and when you can avoid it. The more actors that are running all of their Behaviors off screen, the worse your game's performance will be.

 

Limit the Number of Actors on Screen

This can be tough when you want a game with a lot going on, but if you do need a lot of actors on screen, make sure you use actors you can recycle, i.e. those created with the Create Recycled Actor block.

The following article, Optimizing Actor Performance, explains ways to improve actor performance in detail.

 

Avoid Expensive Calculations Every Frame

In the Always event block, you need to be careful about the types of calculations you choose to run here. The Always event block executes logic every frame, so running calculations that take use a lot of processing power each frame will slow down your game. Examples of calculations to avoid using in the Always event block include trigonometric calculations, random number generation, calculating the square root of a value, and those involving exponents.

 

Limit Use of Effects

The actor effect blocks can slow down your game, especially when applied to a number of actors on screen. These blocks are best used for temporary changes to an actor rather than having them always on. The example of blocks below shows overuse of effects.

 

Limit Use of Custom Drawing

The Drawing blocks under the Drawing category in Design Mode allow you to draw custom shapes on screen.

Using them takes up a lot of processing power, though, so take into consideration how many custom shapes you're drawing on screen at any given time. Consider pre-rendering your effects instead.

 

Don't Draw Multiple Things in the Same Place

When you draw anything on screen, avoid drawing things on top of one another. Doing this wastes processing power since you're drawing over the same spot multiple times.

 

Now it's your turn. Share your Tips.

What have you found, in your experiences, boosts performance of your games when you're in a bind? Use the comments area below to share your stories.



Last Updated: 2013-01-29 by Jon

16819 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!
9 Comments
HannesRoets
For a letter puzzle game what is best (for android) ?
a) make a png image for each letter
b) make one png image and render the text on the blocks

0 3 months, 3 weeks ago
LudicPixels
Does the number of regions in a scene drastically affect the games performance?
0 1 year, 1 month ago
ExplosionsHurt
Just wanted to note that if a collision does not need to be accurate you can get away with using hitTestObject(whatever) instead.
1 1 year, 7 months ago
CSLewin
What are some sample alternatives to using the Always block? I'm making a pong clone and I want to see if the player has scored by checking if the x-value of the ball is less than the x-value of the left-side player's paddle.
0 1 year, 7 months ago
gigaclon
Number 5 is right to warn against using expensive calculations every frame and to say that one way to avoid that is to put them in to conditional blocks as then they will not be done every frame
0 1 year, 8 months ago
gigaclon
The idea for 6 is to only use effects for short lived effects. If you want it to be longer you should just use GIMP to make the changes and put them as another animation.
0 1 year, 8 months ago
Jiab0fficial
If the calculations or performed under an "If" statement block which is usually not true (ie. If mouse button is down), does the calculations under that "If" block get ran as well, or are they ignored/skipped until the "If" block's conditions become true?
1 1 year, 10 months ago
carroll6
3-Limit How Often Actors Use Always Simulate. I do not understand what this means.. "always simulate".. is this a scripting function?
0 1 year, 11 months ago
FunExplosions
For something like number '6', you guys may also want to list an example of what that code *should* look like, not just what it shouldn't.
0 1 year, 11 months ago



Commenting Guidelines

Sign In to Comment

Make Games

  • What is Stencyl?
  • Roadmap
  • Pricing

Play

  • Arcade
  • Showcase

Community

  • Forums
  • Chat
  • Translations

Help

  • Stencylpedia
  • Stencyl TV

About Us

  • Blog
  • Contact Us
  • Press
  • Privacy
Follow Stencyl on Twitter



© 2013 Stencyl, LLC.