Events to Change Textures
- SetTexture – A String when used as a TouchEvent or Dictionary when used as a non-Touch Event. See both examples below….
- SetTextureSafely – same as above but will stop all actions on the Element (this is needed if the Element is animating textures)
- SetTextureFromPool – A String when used as a TouchEvent or Dictionary when used as a non-Touch Event. As a String the value will be the Pool name. The Element will cycle through the textures in the pool starting with the first. When used as a Dictionary key (see below) each key will be the Element to change texture, and the value will be the Pool Name.
- SetRandomTextureFromPool – You can randomize a texture by setting the value of pool. The pool should contain the names of possible textures to use. For example, Cloud1, Cloud2, etc.
- SetTextureFromPreference – The value should be equal to another value you set earlier (for example, using the SetValues dictionary or SetValuesIfNil dictionary). Essentially this is just an in-between reference to the texture. But like any variable, it can change over time. So the user might tap a button to change the value, then change the texture from the preference.
You could also do something like…..
Because SetValuesFromPool (and all SetValue-related code is run first), the event cycles through a new value from the pool, then uses that value for the texture. This would be a great way to cycle through things like clothing choices for a character in your book.
If you stumbled onto this article, it is part of our documentation for the Story Tellers iOS Starter Kit 2. The kit enables you to make children’s book apps and games without writing any code! But it is Swift 2 based and compatible with iOS9 (or higher) and Xcode 7 (or higher), so kit buyers can even extend the functionality to fit their needs further. Some of what we cover in the kit documentation may apply to Xcode in general, so this article could be worth a read even if you aren’t a user. You can purchase Lifetime Updates the kit here, or subscribe Yearly to CartoonSmart and get the latest version, plus access to all of our other kits / tutorials.
We’ve also created an iBook to document the very latest properties in the kit, so be sure to download that as well.