Page 1 of 1

Set Global Var Value to Value of another Global?

PostPosted: Fri Mar 15, 2013 4:39 am
by blitzMN
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!

Re: Set Global Var Value to Value of another Global?

PostPosted: Fri Mar 15, 2013 4:41 am
by blitzMN
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!

Re: Set Global Var Value to Value of another Global?

PostPosted: Fri Mar 15, 2013 5:52 am
by poisonpage
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

Re: Set Global Var Value to Value of another Global?

PostPosted: Fri Mar 15, 2013 6:11 am
by blitzMN
Awesome! Thanks for the quick reply!