Set Global Var Value to Value of another Global?

Get help using Construct 2

Post » Fri Mar 15, 2013 4:39 am

Hi!

First post here so here goes....

I have a global variable that represents the score for the game and on every tick it counts down a set amount. When the player reaches the end of the game I have a collision event that ends the level. What I want to do then is take the value stored in the global score variable ( that is being subtracted every tick ) and set it to another global variable for the final score before ending the level. So to summarize I am trying to set the value of one global variable to another global variable, is this possible?

I am in a time crunch at the moment so any immediate feedback is welcome!

Thank you in advance!
B
5
Posts: 3
Reputation: 700

Post » Fri Mar 15, 2013 4:41 am

Follow up....

Or another way is how can I stop the subtraction of a value on collision with another object? I hope this makes sense.


Thanks again!
B
5
Posts: 3
Reputation: 700

Post » Fri Mar 15, 2013 5:52 am

You could use a triggered event with a second global variable, so on the ending collision event you'd use "System>Variables>Set Value" and it'd look something like "2nd variable = 1st variable". Your second variable isn't counting down as it was triggered once. There's a much better way of doing this though. You can set up a function that will decrement the main score as long as you are in a 'play' state. When you collide and finish the level, change the state of your game to 'end', and since this will stop the score from decrementing, you can apply the score just from the one variable wherever you'd like (high scores table, text/dialog box, database, etc.) Good luck!

Paul
B
17
S
5
G
4
Posts: 24
Reputation: 4,039

Post » Fri Mar 15, 2013 6:11 am

Awesome! Thanks for the quick reply!
B
5
Posts: 3
Reputation: 700


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, mjj1990 and 9 guests