How do I control character placement on layout change?

Get help using Construct 2

Post » Wed Feb 11, 2015 4:58 am

I am working on a side-scrolling game and have been stuck on controlling where my character appears when I have sprite change layouts. Ideally I am going to use the borders as well as "doors" or exits on the layout and so the player will have multiple locations they can appear depending on which exit they came from.

I've been trying the method of using using a sprite box as the trigger to load the appropriate layout. On layout load I am using "set PLAYER to POSITION X and Y". I also tied "set PLAYER to POSITION of object" and placed an object where I want the player to spawn.

Any ideas on how to set where the player loads on layout change?
B
14
S
2
Posts: 5
Reputation: 712

Post » Wed Feb 11, 2015 10:06 am

Hey chromaticcodex, :)

One possible approach:
1. For the exit objects, add a private text variable named "exitName".
2. For each exit object, set "exitName" to a unique name. ... (e.g. "snakeTunnel", "lavaTunnel", "spikeTunnel", "comfyPillowTunnel")
3. Do this for each layout, making sure the doors that are supposed to be linked between layouts have matching names.
4. Now, create a global variable named "gLastExitUsed". ... (globals are unchanged between layouts)
5. When the player leaves through an exit object, get the text in the exit's "exitName" and store it in the "gLastExitUsed" global.
6. Jump to the new layout.
7. On start of layout, pick the exit object with the "exitName" that matches the "gLastExitUsed" global. Place the player at that door, as if they just entered through it.
B
26
S
17
G
8
Posts: 321
Reputation: 6,015

Post » Wed Feb 11, 2015 10:07 am

...I'm not sure where you're having problems? It really sounds like you've got it under control.
That said, if you *were* having problems, fisholith has gone into serious detail for you.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Wed Feb 11, 2015 8:19 pm

fisholith- thanks! I haven't quite figured it out yet, but using what you wrote has gotten me closer, I just don't think I am using the global variables correctly yet. You're awesome though!
B
14
S
2
Posts: 5
Reputation: 712

Post » Thu Feb 12, 2015 2:55 am

Take a look at this fellow, see what you think.
You do not have the required permissions to view the files attached to this post.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Thu Feb 12, 2015 7:55 pm

Unnatural20 - Your fellow there has really helped. For the first time I was able to set where exactly the player loaded on a layout change. The capx is a great starting point. Making it work all on one event sheet is the only adjustment I will need to make, but I think that should be relatively easy but again this is a huge step forward. From the looks of it all I need to spend some time learning more abut expressions. Thanks, both of you!
B
14
S
2
Posts: 5
Reputation: 712

Post » Fri Jul 08, 2016 8:48 pm

@fisholih yeah the method you mentioned was limited, so I added using a dictionary and pasting an "exit group" in each new event sheet.
Image
This took me a week to figure out, but here you go.
Image

How to use dictionay vid:
https://www.youtube.com/watch?v=5GYseCaj6GM
B
15
S
5
G
2
Posts: 164
Reputation: 3,080


Return to How do I....?

Who is online

Users browsing this forum: Aergo, anty21ro, Fenix18, Iftikhar555, oosyrag, radhaw, TeslaPC, TheGreatAdam12 and 13 guests