Moving between layouts with custom coordinates

Get help using Construct 2

Post » Fri Aug 16, 2013 11:40 am

Long story short, here's a graph what i mean:



I didn't find this from tutorials, or from forums.
So, the problem is, how do i get the playable character appear in different spot depending where i exit in previous layout?

For example, if character exits in point B in Layout 2, it starts in point B in Layout 1.

What is the easiest way to do this and do i need several event sheets for this?

Thanks!
B
5
S
1
Posts: 15
Reputation: 788

Post » Fri Aug 16, 2013 11:52 am

Hi Zoneboi. Maybe you could capture the sprites x and y coordinates as two separate global variables as it exits the layout. Then have the sprite spawn relative to those x & y coordinates on the next one?

If this doesn't help I do a mock up and past it on here.

Cheers

H
B
21
S
2
G
1
Posts: 24
Reputation: 3,659

Post » Fri Aug 16, 2013 3:18 pm

This can be done with a single variable. I have a variable that I call "From" and I set its value during the transfer layout event. I have an invisible object at each exit and when you touch it, it sets the From variable, starts a fade out, then transfers you. On the start of the next layout, I have it set the player's position to different places depending on what the value is for From. I then have the map fade in.

For instance, when going from layout 3 to layout 1:
On overlap of transfer, set From to "Layout3" (you can also use the system expression for the current layout name)
Go to Layout 1.

On layout 1's start of layout,
--> (As a subevent) If From = Layout3, set position to 340, 750

Then just have a sub event for each possible From value on each layout's event sheet. In the case of there being multiple paths between two layouts, I just name From to Layout2a and Layout2b and vice-versa.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Sat Aug 17, 2013 1:41 pm

Alright!!

HowieMonster's tip was good, but i had problems with entering in a new layout, because the coordinates were not always relative together. My graph looked like they did, so i apologize. But thanks anyway, it was good tip. Cheers! :)

I haven't tried C-7 tip yet, but that makes perfect sense! Even though I haven't tried this yet, i'm sure it works. Thank you so much!
If this won't work, i'll post .capx -file and hope you won't bang your heads on walls. :)

Thank you!

ZB
B
5
S
1
Posts: 15
Reputation: 788

Post » Sat Aug 17, 2013 3:10 pm

I've made this work in my game but it's kinda hard to explain..

First, my main character is global, so it keeps the variables when the layout changes. Then, I have 3 different variables:

lastDoorType - checks the last door type the character has entered
doorX - The new X position in the layour the player should appear when he moves into a new layout
doorY - Same as above, but with Y

Then I have 2 diferent objects (since my game is a platformer),

doorM0passLeft and doorM0passRight.

I have an image point called "end" on it, so I can check when the character has finished walking into the new layout.

I'm explaining all this so I can just show you my code.




There's probably an easier way but this is working out great for me.
B
123
S
43
G
41
Posts: 847
Reputation: 28,206


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], senecaa, unicornspitfire and 8 guests