?Position On Layout After Exiting A Building? How?

Get help using Construct 2

Post » Thu Mar 21, 2013 5:27 am

Hey guys, I created the account for this question. This site has helped me with alot. Still new to the game creating world.

QUESTION:
I created a basic game so far with 2 layouts (1st layout being "outside on the streets, with one store"), when you collide with the store it spawns me on my other layout (the 2nd layout being "in the store") exactly where I want it to. But when I exit the store and go back to my "Layout 1" (the streets) it spawns me all the way back at the top right of my layout instead of just outside the store. Helpp???




Note:
- I know what "x" and "y" coordinates I need it to spawn when exiting the store. Just dont know what events (and on which event sheets) I should be doing.

Appreciate the help in advance,
D.Rose
B
2
Posts: 3
Reputation: 256

Post » Thu Mar 21, 2013 5:30 am

And please dont foward me to the event sheet manual lol :P That page taught me a lot. But I cant quite catch this one :S
B
2
Posts: 3
Reputation: 256

Post » Thu Mar 21, 2013 5:38 am

can you upload your capx?
i think you need to set a guide sprite or something like that so when the player enter in the store he spawn to the right of the guide sprite and when he leave you should do something like if player is in collition with sprite spawn him in an x,y position in the layer 1.
B
17
S
2
G
2
Posts: 82
Reputation: 1,712

Post » Thu Mar 21, 2013 7:47 am

You'll need a variable like 'Location' which tells you where your player object just was. Then, create a 'start of layout' event and add sub events like:

Location='Store'
.. set position to X,Y

Location='Street'
.. set position to X,Y

Set location to WhatEverLocationCurrentLayoutIs

That is one way to do it, there are probably better ones :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Thu Mar 21, 2013 8:53 am

Well I think it should work if you create 2 global variables called StreetX and StreetY. Make sure the initial values are the X & Y where you want the player to start the game. So as vee41 says, on the street level do a 'On Start of Layout' event and create 2 actions called [Set Player X to StreetX] and [Set Player Y to StreetY].

Thee second part is that when the player collides with the store, create an extra 2 actions which are [Set StreetX] and [Set StreetY]. Make sure these are the X & Y values you want to player to reappear in when leaving the store (set them just a little away from the store so the collision event is triggered again).

You could do this for every building your player goes into, so they always return to where they were when back on the streets.
B
13
S
4
Posts: 127
Reputation: 1,479

Post » Fri Mar 22, 2013 5:38 am

You guys are the best. This forum thing really does help. I'm guessing that the free edition of Construct 2 doesn't have Global Variables in the projects tab lol? Don't see it anywhere there.
B
2
Posts: 3
Reputation: 256

Post » Fri Mar 22, 2013 6:01 am

right click in the event sheet and it should be there
B
17
S
2
G
2
Posts: 82
Reputation: 1,712


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, randomly, spcsmrf and 23 guests