1: Getting Started
2: Building Logic
5: Game Mechanics
6: Advanced Topics
7: Testing & Tuning
8: The Last 10%
M1: Mobile - Intro
M2: Mobile - Basics
M3: Mobile - Services
M4: Mobile - Publishing
B: How-To Guides
3.0 Drafts (In Progress)
Drawing Text with Labels (Mobile)
Most games draw text to the screen. In mobile games, this method negatively affects game performance if used in excess, so we use a different method. There are two ways to draw text in mobile games for Stencyl:
Note: In Stencyl 3.0, it is OK to draw text directly. You can still use labels (described below), but drawing text directly, if used in moderation is now acceptable.
Whichever method you choose, all text drawing involves three main properties
Drawing Text with Labels (Stencyl 2.2 and below)
Note: In Stencyl 3.0+, Labels are now an extension, rather than a behavior on StencylForge. Go to Game Settings > Extensions and enable the Labels extension. Close and reopen your game, and you'll find the Label blocks under the Custom Blocks category.
Labels are a special kind of actor that can display text. You can specify a font and text to draw for this actor. Like any other actor, a label has a position, rotation, opacity, and can have behaviors attached to it.
We recommend you use labels to optimize your game’s performance. Labels draw text quickly because they change infrequently. The drawback? They require a little more work to set up.
How to Create a Label
1) Create a blank Actor with a blank Animation.
2) Attach the “Label” behavior to the Actor. You'll find it under FROM YOUR LIBRARY > Utilities.
Note: If you're using Stencyl 1.4.1 or earlier, visit StencylForge and search for “Label for iOS” -- Download it
3) Configure the behavior to your liking. (Note: Current versions of the behavior may have more fields than this)
4) Add the actor to the desired scene. If you find it inconvenient that the Actor is "invisible", you can assign a dummy animation to the Actor. It won't display in-game.
How to Change a Label’s Text and Font
The “Label for iOS” behavior comes bundled with some custom blocks that let you change a label’s text and font. Look for them under the Custom category.
How to Move a Label Around
Labels are actors! You can move them around just like you’d move a regular actor around, setting the label’s position, setting the label’s speed, or a using motion tween, for example.
Drawing Text Directly (Stencyl 3.0+)
Draw text inside the “when drawing” section of a behavior, as shown below:
In Stencyl 3.0+, this no longer incurs the heavy performance penalty that was present in prior versions. You can still use labels (via an extension as described in the prior section), but this method is simple and likely the one many will use.
Drawing text will be simplified in the future for basic use cases. You'll be able to place a label directly in a scene from the scene designer and assign it a font and default text. You'll also be able to refer to it as a regular actor from behaviors.
Last Updated: 2013-04-10 by Jon
10022 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!