How do I Adjust Positioning While Moving Between Levels?

Just started using Construct 2? Post your questions here

Post » Tue Jan 05, 2016 12:12 am

I'd like my sprite to move between rooms, or levels.
How can I make sure it is appearing at the appropriate spot?
I've added an invisible object and set up my events so that when my player overlaps the object, the system switches to the new level. That's good to go.
However, when entering the new room from the left, I need the player to appear on the new level on the right side of the screen, and vice versa. Please see my screenshot:

https://www.dropbox.com/s/qbqr2emvpj61f ... e.png?dl=0

(I need the player to go from position 1 to position 1, 2 to 2, 3 to 3)
I have my player sprite set to global so that instance values are retained between levels.
How should I set up my event sheet so that my sprite is entering each new room properly?
B
7
Posts: 51
Reputation: 379

Post » Tue Jan 05, 2016 1:15 am

You could give an instance-variable to the overlapping objects, on overlap set an instance variable on the player to it and check for that variable on start of the new layout and set the player position accordingly..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jan 05, 2016 6:09 pm

I'm sorry, I don't understand :-(
B
7
Posts: 51
Reputation: 379

Post » Tue Jan 05, 2016 10:40 pm

He means you need to have some sort of variable or way to keep track of what the last room/door was. So right before you change layouts, set a variable to either a value of your choosing or the layout name if you don't have multiple doors between two rooms.

Then, on the start of your layout, check what that location variable is set to and reposition the player based on that. This is an excellent place to use sub events for good organization.


So On Start-
If location = a, set position to whatever
If location = b, set position to a different place

And so on.
B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Wed Jan 06, 2016 12:45 am

Okay, so I've put an instance variable called "PortalFrom" on each invisible overlap object in Level 1_A and numbered them 1-3.
I've done the same with 3 position markers on Level 1_B and called the instance variable "PortalTo".
I'm trying to make it so that when the sprite overlaps something with the instance "portalFrom(1)" it is sent to the location of "PortalTo(1)" on the next level.
It's not working. In the "Set position to" action, there is no place to specify the instance variable number for "PortalTo".
I'd hate to think that I'll have to create a new sprite for each PortalTo location throughout the whole game!
It looks like this:
----------------------------------------------------------------------------------------------------------------------------
>When Player overlaps object | PortalBricks| Action: Go to next layout|Set position to PositionMarker
>>PortalBricks: PortalTo= 0 |
B
7
Posts: 51
Reputation: 379

Post » Wed Jan 06, 2016 2:24 am

Something like this should work:

Create a variable WhereTo

When player overlaps object portalbricks
> System set variable whereto to portalbricks.portalto
> goto next layout

On start of layout
- Portalbricks compare portalto = Whereto
> player set position to portalbricks
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 07, 2016 12:25 am

Hmm, it's still not working. I don't know what I'm doing wrong!
Image
B
7
Posts: 51
Reputation: 379

Post » Thu Jan 07, 2016 9:35 am

Seems to me, the on start of layout is meant for the new layout, right?
Are all layouts using the same event sheet?
In that case it might be wiser to have a seperate event sheet for each layout and use include event-sheet for all events that are global..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 07, 2016 2:23 pm

I have many event sheets, but they all feed into one main one.
But, I give up.
Thanks for your help anyway!
B
7
Posts: 51
Reputation: 379

Post » Thu Jan 07, 2016 3:42 pm

Milanbaudelaire wrote:I have many event sheets, but they all feed into one main one.
But, I give up.
Thanks for your help anyway!


Don't give up..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests