How do I pin two global variable?

0 favourites
  • 3 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • I have two gloal variables and a button. when i click the button increase "a" variable to 1 and increase "b" variable to 10. every 1 second subtract "b" 1 and every 10 second subtract "a" 1 .

    So i click button 4 times then "a"=4 ,"b"=40 . I save this data n localstorage and after 6 second i exit the game . when I' back : "a"= 4 and "b"= 34 . In another word : "b"=34 when i'm back, after 4 second "b"=30 , and then subtract from "a" 1.

    or : "a"=6 "b"=60 , 8seconds lef "b"=52, after 2 second should "a"=5.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The thing is, you never enter the "Every 10 seconds" event (you never stayed 10 full seconds for it to pop), but you do enter the "Every 1 second" event.

    To keep data persistent, I'd suggest creating another variable and add 1 to it every 1 second. Then, if it's equals/bigger than 10, subtract 10 from it, and reduce 1 from a.

    Save it in the localstorage as well, this should do the trick.

  • thanks bro.that's cool way

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