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)
What are Lists?
If you've ever written a grocery list, you're prepared to use lists in Stencyl.
Lists let you record pretty much anything in a predictable way. If you add apples to a list, and then add oranges, when you read the list apples will always come before oranges. However, lists are useful for more than just remembering what to pick up from the grocery store.
For Programmers: Lists are mutable lists. They are equivalent ArrayLists, Vectors, NSMutableArray or whatever you like to call them.
What are Lists useful for?
Lists are best used to store, well, collections of things. You can use lists for things like:
Lists can be a good option any time you want to keep track of lots of information.
Note: Internally Stencyl uses lists to keep track of created actors, what points in a collision actually collided, and so on. If you've used any block that begins with "for each" you've actually used a list already!
A list is an ordered collection of items. Each item in list is made up of two parts:
Think of a list as a 2-column table.
All blocks related to lists are located under Attributes > Lists.
Coming Later: As of Stencyl 2.0, we don't support reversing, combining or sorting lists. These operations may be available in the future though! We're also looking into adding Dictionaries (also known as Maps), which map arbitrary keys to values.
How do you create a List in the first place? Lists can be Attributes, so like any attribute, there are two ways of doing this.
Assume that for both cases, we have created a List Attribute called "myList"
Method 1: Configuring a List Attribute
After attaching a behavior with a List attribute to either an Actor or a Scene, you'll see this neat interface for adding initial data to the list.
Note: The second icon (the one under the +) lets you import a List from a text file. One line per entry. All entries will be treated as text.
Method 2: Creating it on the Fly
Alternatively, you can create a new list on the fly and begin filling it up.
Lists as Game Attributes
Lists can be used as Game Attributes. This can be pretty useful for defining stat tables and other large collections of data to use throughout the game.
Creating a List as a Game Attribute
Lists can be created as Game Attributes and pre-populated the same way as other lists, namely only with Numbers and Text.
Note: You are also allowed to dump in Lists into Lists at runtime as well as any other kind of data. If you plan to save your lists out (via Game Attributes), there are restrictions. Skip down to "Saving & Lists"