How do I replace Global variables?

Get help using Construct 2

Post » Wed Jun 28, 2017 12:40 pm

Hello!

I don't know if it is possible at all. but is there a way to replace a global variable?

Like e.g. I got some lines of events with a global variable in it, which is bases on 2 different players.
Now I want to copy and paste that line to make the 2nd player but that global variable is quite often in it, so I had to replace it manually every time.

Is there a way to do it or maybe just a faster way to make it manually? I solved this problem by making player-specific sprites which are not implemented in the game itself but serve as a variable safe or something like an array. Later, I can copy+paste the events/movements or player 1 to player 2 and just replace player 1 stat object with the player 2 stat object.
B
13
S
2
Posts: 80
Reputation: 821

Post » Wed Jun 28, 2017 1:24 pm

For the objects you could do with instances rather than different object types.
As for the global variable, unfortunately, a global is global to the whole project, so no easy way than replace it manually indeed.

The advantage of instances is also you can handle instance variables with them.
And finally, with instances, you only need to apply your movement code once, all that changes is the condition for picking.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
291
S
114
G
95
Posts: 7,293
Reputation: 70,144


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo and 30 guests