GameMaker: Studio

GameMaker: Studio

Προβολή στατιστικών:
How do i make two globals change their places?
Hello, Everyone!
Here's the thing. I want my two global variations to take each other places.
Let's say it is "global.first = 2 and global.second = 4". I want them to became: "global.first = 4 and global.second = 2" and vise versa by pressing a button.
If anybody knows how to do this, please tell me
< >
Εμφάνιση 1-3 από 3 σχόλια
The way I do this is to just create a temporary variable before switching them like this:
remember = global.first;
global.first = global.second;
global.second = remember;

There might be a better method but this one works.
The var keyword is a good concept to look into, on that. It creates a variable that basically only exists until the present block of code finishes running, and it's surprisingly handy.
Thank you, guys! You are realy saving me
< >
Εμφάνιση 1-3 από 3 σχόλια
Ανά σελίδα: 1530 50

Ημ/νία ανάρτησης: 21 Απρ 2014, 7:22
Αναρτήσεις: 3