Switch to Book Layout1: Getting Started2: Building Logic
3: Actors
4: Scenes
5: Game Mechanics6: Advanced Topics7: Testing & Tuning8: The Last 10%M1: Mobile - IntroM2: Mobile - BasicsM3: Mobile - ServicesM4: Mobile - PublishingA: Troubleshooting
B: How-To Guides
C: ReferenceD: Resources3.0 Drafts (In Progress)
|
||
|
Level: Beginner
Drawing Text with Labels (Mobile)Contents
IntroductionMost 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.
BasicsWhichever 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 Label1) 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 FontThe “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 AroundLabels 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.
The FutureDrawing 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!
8 Comments
Jon
Losh started a topic here for those who want to localize games. (http://community.stencyl.com/index .php/topic,19118.0.html) 0 1 month, 2 weeks ago
nuclearsheep
can you explain in the "how to change a label's text and font" category, where exactly to put those blocks? this process is not working at all for me :/ 1 1 year, 1 month ago
MerlinoDreamlab
It's possible to have multiline Text, Alignment and something for i18n? Would like to use iStencyl for some Multimedia eBook iPad app like one we have already created (http://goo.gl/tyvK7) 1 1 year, 4 months ago |















