Two students in my "mobile gaming" course are pursuing final projects that involve some sort of collection mechanic. One student is reskinning the classic breakout game and another student is creating a language learning game that teaches users basic Swedish.
In both games, players are collecting objects along the way. On the final layout, we would like to be able to display all of the collected objects on the screen.
For now, we're not worried about positioning on the page. We would simply like to be able to quickly check to see if an item was collected or not. If the object has been collected, it should be displayed on the final page.
At first, I thought we might be able to do this with families. All of the collectable objects could be added to a family, and a family instance variable (isCollected) could be used to keep track of whether or not the variable was picked up. Then, on the final page, we could just loop through all items in the family and check to see which items should be displayed.
Unfortunately, as you can see from the linked file, this solution doesn't seem to work.
transmedia.trinity.edu/~adelwich/temp/sample-collection-approach.c3p
Debugging the file reveals that collecting the item successfully sets the isCollected instance variable, but then the object disappears on the next level. I have applied the 'persist' behavior to the entire family, but that doesn't seem to do the trick.
I also tried making all of those objects global, but then the objects appeared on every single layer, even when they weren't supposed to be accessible.
I would be grateful for any advice. In other programming languages, I would try to tackle something like this by putting references to the objects inside an array. Is that the preferred approach for C3?
Thanks!