How do I Stash quantities?

0 favourites
  • 4 posts
From the Asset Store
A grab of sounds and loops crafted with the Producer in mind.
  • Hello! I am working between three separate Layouts just to try out the Engine before purchasing. Layout 1 is the game play It has a space ship that can be destroyed. Layout 2 is a Home screen that gives you the number of ships you have left and the number of coins you have earned in play to possibly buy ships with. (working up to an eventual "In App Purchase.") Layout 3 is a market place for buying ships with coins. I havn't really worked in coins yet I simply have it set up so that The Start Button for Layout 1 cannot be clicked unless Number of Ships is greater than 0. There is a bttn sprite for a Market Place and an emty ship sprite with a Text box set to "x"&NumOfShip(A global variable.) I click on the go to Market Bttn and it takes me to Layout 3 where If I click on a ship sprite it adds 5 to the global variable NumOfShip. I return to Main Mentue via another Sprite Bttn attaching L3 to L2 and I see that the Text Box has gone from "xO" to "x5". Awesome that seems to work fine. I hit the play again bttn It now takes me to Layout 1 I play one game. A ship is destroyed(I set up an Action to subtract 1 from the NUmOfShip var on destruction of the Ship.) The game ends I'm back at the home screen and my ship text says "x0" Wait! 4 ships went south! Obviously this will not work if I ever buy a plan an add In App Purchase. People will certainly be very angry with me. So I need to know how to stash/save a variable like number of coins or number of plays left before purchase needed, so that It doesn't reset on every restart of the Layout. Oddly it doesn't reset going from Layout 3 to 2. It seems to only reset between the home screen and the Game Scene or maybe vise versa. Obviously there is a way to do this I just cant seem to find it.

  • It's not possible to answer your question without seeing the project file. The NUmOfShip variable obviously gets reset somewhere. Most probably there is an event "Reset global variables" that does this.

    There are many ways to keep this value safe and intact. You can use a dictionary, or put it into an instance variable, or save to Local Storage etc.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes! that was the problem. Thank You! NOW of course the pickle is to make all of the variables for the game play reset on restart of Layout. I guess I need to either reset them individually or make them locals. I see a lot of people referencing Local Variables are these not included in the free version? I cant seem to find them in the "Add" drop down window.

  • Local variables are just variables that are defined inside of events or event groups. They are visible/accessible only from inside these events, hence the name "local". If you set local variable as "Static", it will not be reset.

    Like I said, there are other ways to store values that you don't want to be reset, you can put them into a dictionary for example.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)