Decaying Instance Variables

Get help using Construct 2

Post » Thu Jan 03, 2013 6:40 pm

I am almost ready to dive into "webstorage" which intimidates me a bit. Before I do I want to ask about creating a state of decay for my Tree which has 5 instance variables with different values.

My tree has 3 animation states and over a browser session (lets say 10 minutes) I want my tree to decay instance variables at random in increments (some -3 some -1)

My tree is set to 55 total instance variables when it falls below 34 it takes its second animation.

How would I go about setting up this sequence of events?

Obviously in the future I want to make my decay state longer and associated with the Player and webstorage so when Player returns to a session the tree is in its previous state.

Thanks in advance.

One footnote I have to say this is the most badass peice of software and community that I have ever seen. I am extremely impressed!
Posts: 25
Reputation: 825

Post » Thu Jan 03, 2013 7:49 pm

Web storage is simple. You're just storing pairs of keys and value. The keys are strings, the values are strings or numbers.

For example, to store the player score:
WebStorage: Set local key "score" to 500
Then when you want to get that value from web storage you do:
Set variable to WebStorage.LocalValue("score")

You can easily save an entire array or dictionary to webstorage by saving it as JSON.
WebStorage: Set local key "savedArray" to Array.AsJSON
Array: Load from JSON string WebStorage.LocalValue("savedArray")

For your tree I suppose you could do something like

System: Every x seconds
System: Compare two values floor(random(100)) < n
   -> Tree: Subtract floor(random(a, b)) from var
(Every x seconds there is a n% chance to subtract a value from a to b-1)
Posts: 1,520
Reputation: 25,870

Post » Thu Jan 03, 2013 11:58 pm

magical... and great detail on the webstorage. I appreciate it.
Posts: 25
Reputation: 825

Return to How do I....?

Who is online

Users browsing this forum: Konstantin313 and 7 guests