As described in the initial setup article labels (technically speaking, SKLabelNodes) can simply be dropped into the scene and supplied with whatever text you want. The Story Tellers iOS Starter Kit 2 gives you plenty more options though. The kit can even read back text in a label with country-specific voices. Lets first discuss making labels dynamic, and by that I mean, changeable based on a saved value (preference) in the kit.
Labels with dynamic values are relatively simple to setup and only have a handful of properties. But you can use them to dramatically change your book. The label could display the reader’s name (and that name would be remembered every time the app is opened), the label could show the time remaining to play a game, or the value of anything you set using the various SetValue events or opening the iOS Keyboard. You could even give readers the option of changing the core story of the book by letting them fill in the blanks or change outcomes.
To set this up, all you need to do is drag out a Label from the Object Library into the scene and give it a Name property. For example, WelcomeMessage.
Then in either your page dictionary or in the Root, create a Labels dictionary, then a sub-dictionary with a matching name, so again, in this example, that would be WelcomeMessage.
We can now set the following properties which will change the label at runtime….
TextWithSavedValue – Enter the saved value name to swap with the main text. For example, you might enter UserName so at runtime whatever the last saved value for UserName would be used for the text.
MaxCharacters – a Number value for the max number of characters the label would show.
TextIfNoSavedValue – If a saved value can’t be found, you can use alternate text you specify here.
Prefix – enter any text to appear in front of the main text.
Postfix – enter any text to appear after the main text.
PrefixFromPool – Random prefix text from a Pool array (see the image below). The value should be equal to a pool name in the Root of the property list. For example, WelcomeMessages, would pull a random value from the three possible options below.
PostfixFromPool – Random postfix text from a Pool array
TextFromPool – Random base text from a Pool array
TextFromLanguage – a Dictionary defining text for a different language. ANY language, Klingon, Elvish, its up to you.
The “Language” value should be set initially using the SetValuesIfNil dictionary with a key named “Language” and the default language as the value. This could be set in a Page dictionary or as an event.
Keep in mind labels can be treated like any other node. So the same actions or properties that can be run on any node, apply to Labels as well. You can stick them to other nodes, run actions on them, hide / show them, etc.
Become part of the CartoonSmart Team with our Affiliate Program
Make recurring money when you refer a subscriber. 30 day tracking. Commissions 33%-50%!