Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
Issue: Transferring saved Int's from one global to another.
  • Hey Guys.

    I currently have a game where i track a score as a user goes through a goal.

    On game over, I want to display their current score so I:

    RulesMap.

    When - Event Captured - Collision - Is started - W/ Carrot

    Local Storage.

    Action type: Store

    Storage LN: Globals.Data.CurrentScore

    Save Data From: @Properties.score

    I when move to my game over screen and I have two triggers:

    1) To load the above

    2) To show the loaded in @renderer.text

    On my game over screen and all this works fine, my issue is with the below.

    The ISSUE:

    When the currentScore is > than bestScore, i want to trigger the save button to save the global property of currentScore under the global property of bestScore.

    The button is working fine and displays only when the currentScore is > than bestScore

    When i click the save button as it has now triggered, i replay the level again but when i die this time, the bestScore does not display.

    Is the issue not being able to save a global property from one place to another?

    My code for the Above:

    Save Button:

    Rules Map: Logic_TouchDown

    When Mouse is Down:

    Trigger:

    Local Storage: StoreScore

    Storage Name Location: Globals.data.bestScore

    Save data from: Globalsdata.CurrentScore.

    (I have tried "Save data from: @renderer.text)

    To display this score on the HighScore entity on my GameOver Screen I:

    RulesMap: Logic_OnLoad


    When - Level - Level Loaded

    Trigger: (LoadScore)
    Local Storage:

    Action Type: Load

    Storage Name Location: Globals.data.bestScore

    Load Stored Data to: @renderer.text (Text of where i want to display the highscore number)

    Trigger: (ShowScore)


    Change Property:

    Property: @renderer.text

    = Type Reference

    Globals.data.bestScore


    So now, when i play the game, score a point and then die, game over screen triggers which displays the currentScore i had while i was playing. The score is greater than the highscore (bestScore) so the save button triggers, i click save which should then save the currentScore as bestScore. I replay the game, die, gameover screen but the highscore (bestScore) is still 0 and not the saved score i saved in the previous game. (I have a replay button on the gameover screen. I am not, closing the flash and launching the game again.

    I have also tried the method of saving the score to local space on my PC via the use of "NameOfFolder" but that will not work either.

    I have tried only using @renderer.text to save the number the text was currently at when i clicked save. Didn't work.

    I have tested the above via changing the global properties of both CurrentScore and bestScore globals and everything works as it should except for the saving CurrentScore as bestScore and displaying the bestScore on the levelLoad.

    Maybe i can not save a global property from one place to another?

    I really hope this is not all too confusing XD.

  • 1 Comment sorted by
  • @Vabble ok couple suggestions. Local Storage should not be used in this way. You should really only trigger local storage on receiving the system deactivate event or on a level unload to store data to the local device all at once. The way that the local storage works is by passing a Data component and all the properties on it will get saved using the property names as keys. The alternative to that approach is If you just want to save one property which you will then pass a property name (with quotes around the string) which will be used as the storage key and then pass a value or point to a property with the value you want to store.

    Which approach are you taking? Maybe post a screenshot of your storage action. 

    If you are using global values to track currentScore and bestScore you should just store that values directly in the global properties and use them on the game over screen. The only time you should load the bestScore from storage is on game startup and assign it to the global property. You should not take the currentScore, save it to local storage, then reload the level, then load the best score again. That is not an ideal flow.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tagged