How do I Keep Player Position When Changing Layouts

Just started using Construct 2? Post your questions here

Post » Sat Aug 22, 2015 2:45 pm

Sorry if this has been asked and answered somewhere else but I really don't even know how to search for my answer. I am not sure what you would call the thing I am trying to do but I can relate it to something like Pokemon. In Pokemon you have a player controlled character that moves across a tiled open world map. Occasionally if you step on a specific tile it will do a sort of layout change to take you to a battle sequence. Once you have completed the battle sequence it will change back to the previous "layout" of the open world, now here is where I am having a problem, right on the tile you were before the battle. So I made a little demonstration to try and figure this out and here is what I have.

Image
In layout1 we have the player(red box), two planets(blue and green dots), and two triggers(red dots inside "planets"). I currently have the events setup so that if the player collides with either trigger it will switch to layout2 or layout3 depending on the trigger.
Image
In layout2 we have the player again and another trigger(this time a black dot). For the events on this one I have it so that if the player collides with the trigger here it will return to layout1.

So now onto my problem. I want this setup to place my player back at the planet it came in from when it leaves layout2 or layout3 and transitions back to layout1. In layout1 the player spwans into the game in the top left quadrant. If I were to go down to the green planet and transition into layout2 and then touch the black spot to transition back to layout1 I am now back at the top left quadrant instead of on top of the green planet. I am racking my brain but cannot think of any way to do this without doing a save/load sequence that would save the game right as the player touches a planet and then loads back to that save when they touch the black dot, essentially ignoring the progress made on layout2 or layout3 when returning to layout1.

Phew, sorry for the long read but any help with this will be greatly appreciated. Also I only just started working with Construct 2 today so I may need some extra simple instructions.
B
2
Posts: 2
Reputation: 154

Post » Sat Aug 22, 2015 3:56 pm

Image
Image
Using the global variable to save the coordinates before changing the layout.
In the next layout, the player coordinates are load from the global variable.
B
5
S
1
Posts: 3
Reputation: 692

Post » Sat Aug 22, 2015 5:35 pm

Beautiful, that works perfectly and is really easy to set up. Thank you very much for the help.
B
2
Posts: 2
Reputation: 154

Post » Mon Apr 04, 2016 9:28 pm

Looking at this as a possible fix for a problem I am having... Question: does each layout have to have it own event sheet for this to work?


Answer to my own question: it would appear so. ;)
B
18
S
6
G
7
Posts: 44
Reputation: 4,665

Post » Fri Apr 15, 2016 6:30 pm

This makes so much sense after being told. Thanks a bunch. This same issue was bothering a few weeks ago when I was playing around with different game types.

Aaron
B
13
S
4
G
1
Posts: 31
Reputation: 1,439


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 6 guests