How to build up and store in-game money/items
In my game, you are a fly in a spiderweb. You avoid the spiders while rescuing other bugs that got trapped in the web. The object is to stay alive as long as possible. I would like the game to keep track of the total number of bugs rescued, so that eventually I can add an in-game store where you set the bugs free to purchase new flies/other items. Right now the game doesn't have a store, but I would like it to still keep track of all the bugs that have been rescued over the lifetime of playing the game. I watched some tutorials and got the high score to save upon closing/reopening the game using tables. However, when I try to apply the same technique to the rescued bugs, it doesn't work.
So during play it shows how many bugs you are catching at that time. Then on the main menu page it will show the total amount of bugs over the lifetime of your game play. I need to know how to add the current bugs rescued into the total bugs rescued on the menu page. I cannot get it to show the proper number and also need it to reload on the main menu page when you play again.
I know there is a solution to this, but I can't figure it out. I've looked on gamesalad and the web, can't find anything. Please help me.
Best Answers
-
ExplosiveGamer Posts: 33
This should work.
Set up two game integer attributes. (you may already have one of them)
For now i will label them as: "igbugscaught" and the other "totalbugscaught"Have an actor in the game do this:
Rule
If
collision with bug (or how ever way you want to detect when a bug is caught)
do
change attribute
game.igbugscaught to game.igbugscaught+1Now that should keep record of what is caught during the actual gameplay.
So what you want to do now is add what they caught to the total, right?
if so this is what I would do.
I'm assuming that you already have something to dictate when the game is over... whether it's life points or time or w.e...Have an actor in the game do this:
Rule
if
self.time > 60 (or what ever you use to dictate the game is over)Do
change attribute
game.totalbugscaught to game.totalbugscaught+igbugscaughtsave attribute
game.totalbugscaught as t (or w.e you want to save it as)THEN
change scene to Gameover (or what ever your end game scene is)
Make sure to have an actor in the scene before the actual game play that does this:
Load attribute
from t to game.totalbugscaughthope this helps!
Answers
@ExplosiveGamer
Thank you for your answer. All the videos I watched and I still missed how to do the very last save/load attribute actions. I was just doing them wrong. Thanks again for your detailed answer, it seems to be working properly now!