How do I switch layouts and set player position?

Get help using Construct 2

Post » Tue Jul 15, 2014 12:55 am

Current have 2 Layouts. I have a "trigger" setup when my player collides that it will switch the layout and set the position of my player. The issue i'm having is that when i try to go back to my first room, it's placing my player at the beginning instead of the position i'm specifying. Can anyone help provide some insight on what i'm trying to do or recommend a tutorial?

help.png


Thanks!
You do not have the required permissions to view the files attached to this post.
B
12
S
3
G
1
Posts: 35
Reputation: 838

Post » Tue Jul 15, 2014 10:22 am

Construct will never run the "set position to" event because it goes to the new layout first. Even if you put the event before going to the new layout it still won't work because it will move your position in the current layout.

You'd have to set the position using the new layout's event sheet using "start of layout" events. It might also be better to store the position you want to start at as "global" variables especially if moving back and forth between layouts, so for example when you collide with your trigger:

Set global variable startxpos=1066
Set global variable startypos=603
Go to layout "Room 2"

And in "Room 2" event sheet something like:

Start Of Layout
Set position to startxpos & startypos.

Obviously it's pseudo code and not the exact events but you get the idea.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Fri Jul 18, 2014 4:24 pm

Minor wrote:Construct will never run the "set position to" event because it goes to the new layout first. Even if you put the event before going to the new layout it still won't work because it will move your position in the current layout.

You'd have to set the position using the new layout's event sheet using "start of layout" events. It might also be better to store the position you want to start at as "global" variables especially if moving back and forth between layouts, so for example when you collide with your trigger:

Set global variable startxpos=1066
Set global variable startypos=603
Go to layout "Room 2"

And in "Room 2" event sheet something like:

Start Of Layout
Set position to startxpos & startypos.

Obviously it's pseudo code and not the exact events but you get the idea.


Thanks for the help. Global variables are my new best friend :D
B
12
S
3
G
1
Posts: 35
Reputation: 838

Post » Wed Jun 01, 2016 1:06 pm

How do you do if you only have one event sheet for both layouts ? W_w

EDIT : sorry for the bump, I found my anwers ! :geek:
B
5
S
1
Posts: 14
Reputation: 357


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests