How do I get my player to the same place as before?

Get help using Construct 2

Post » Tue Apr 26, 2016 10:11 pm

So I have this following setup. I got 4 layouts, which two of them are used for my menu,. The other two are the main layout (where the main game occurs) and a house layout (which is like a house that holds a npc inside). But the thing is, when I get inside the house and leave it, I return to the start of the main layout again, and not on the location i was before. Is there any way i can fix this in order to make the player return to the place where i was before (in this case near the door of the house, where i entered)?
B
3
Posts: 3
Reputation: 181

Post » Tue Apr 26, 2016 10:23 pm

Try to set your object to Global, so it won't be destroyed when you switch layouts.

More info here :
Common instance properties
B
6
S
2
G
1
Posts: 4
Reputation: 913

Post » Wed Apr 27, 2016 6:15 pm

Message: thepemo can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
FoxFiesta wrote:Try to set your object to Global, so it won't be destroyed when you switch layouts.

More info here :
https://www.scirra.com/manual/71/instances Common instance properties


I have tried by setting it Global but when I return to main Layout he doesn't appear. But I'll try to check with the guide you gave for better informations, so thanks anyway :)
B
3
Posts: 3
Reputation: 181

Post » Wed Apr 27, 2016 10:58 pm

Set a few instance variables in your player's controller sprite (or, if player isn't global, in an invisible global sprite's instance variable or even a global variable). Name them something like "StartX" and "StartY". Set them as numeric and make them static (static is only important for local and instance variables, not for global). When you leave a layout, set the variables to the x and y (respectively) of the spot you want them to enter the next layout at. You can do this just before the "go to layout" action. Then, on the layout start, make the player's x and y = the variables StartX and StartY values. This way, you can start anywhere you want from any layout, including your menu. It's like creating a landing pad.
B
17
S
7
Posts: 21
Reputation: 1,711

Post » Wed Apr 27, 2016 11:20 pm

There's a behavior called "Persist." Just give it to everything you need the game not to reset. When you actually want to reset the game, like when the player dies, add the action "System -> Reset Persisted Objects" in your events.
Eh, Steve!
B
115
S
54
G
13
Posts: 112
Reputation: 16,150

Post » Wed Apr 27, 2016 11:29 pm

This is good for quick games, but for longer games, sometimes you need more control over individual items. Imagine Samus in Super Metroid. We want her position to persist, the enemies to reset, and the powerups remain collected (persist). Otherwise a missile or energy tank could be re-collected every time the area's persistence was reset. It's also a bit easier to track when you have a boatloat of objects. Persist and reset persisted objects are still very important, but there are occasions when the extra control is essential.
B
17
S
7
Posts: 21
Reputation: 1,711

Post » Wed Apr 27, 2016 11:39 pm

I was battling the same problem with certain layout that didn't need things on layout so I had to dump all my Ui icon ish on a family and just made them invisble not destroyed just not seen and made sure that the event sheet for the UI was never used. And I even had to disable the movement control on player.

It does work just that its very annoying wished that there as an ability to choose which layout to be persist for and which layout to never appear.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Thu Apr 28, 2016 8:19 pm

@davemon Ok but how can I set, on start of layout, my PlayerX coordinates to StartX varibable (the same for the Y coordinate)?
B
3
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Jackriduk and 25 guests