How do I maintain the same position across layouts?

Get help using Construct 2

Post » Fri Apr 18, 2014 7:13 am

Im making a game in which the character switches between the past and present on keypress, to get to the exit via portals. my question is , how do i get the character to stay in the same place as when you pressed the key after switching layouts? currently it just goes to the default position.
B
5
Posts: 3
Reputation: 293

Post » Fri Apr 18, 2014 9:23 am

If both layout are identical in size, when one layout ends, store the player X and Y in a global variable. (system, set value A to player.x; system, set value B to player.y)
Then on the next layout, on "start of layout" set the player.x and .y to the global variable number :D (player, set X to valueA; player, set Y to valueB)

Think that should do it :D
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Fri Apr 18, 2014 9:26 am

the player can switch between layouts at any time to solve the puzzles. this will work for it?
B
5
Posts: 3
Reputation: 293

Post » Fri Apr 18, 2014 9:28 am

that's exactly what global variables are for, they persist throughout the entire project.

you can have them on one eventsheet, and since they are "global" you can even access them from another eventsheet no problem. meaning all global variables are shared form every single part of the project :D

https://www.scirra.com/tutorials/804/co ... -variables
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Fri Apr 18, 2014 12:33 pm

thanks a lot. :)
B
5
Posts: 3
Reputation: 293


Return to How do I....?

Who is online

Users browsing this forum: dop2000, R0J0hound, StillSarah and 22 guests