Level Change w/ Coordinates?

Get help using Construct 2

Post » Sat Aug 04, 2012 10:51 pm

Hey, been reading the forums for a couple weeks now but I have my first question that I cant seem to find the answer to in the tutorials / forums.

I have a simple event-based level change when player collides with a marked off sprite area it triggers the system event to change layout to, say, Level 2. Problem is, it just uses the default player position when i appear in Level2. If I set the even to "set position of player" after it changes layouts, it seems to ignore it.. in fact it seems to ignore all events after that level change.

So.. is there a way to determine what the "last level" was? Then I can have a condition on layout start that says if it's coming from A, set player position to X,Y. If it's coming layout B, set player position to X,Y.

Or is there another way I should be setting the player position / changing the level?

Thanks a million you guys all rock.

Nate
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
23
S
7
G
3
Posts: 375
Reputation: 4,797

Post » Sat Aug 04, 2012 11:41 pm

Without seeing a capx or screenshot it's hard to determine the problem, but if you just want to check the last level then you could have 2 variables, one for the last level and one for current level so it be like this.
       

       current level    Previous level
level1 var1=1           var2=1
level2 var1=2           var2=2
level3 var1=3           var2=2
level4 var1=4           var2=3

Then just use each one as you need them

I guess the best time in changing the variables would be "on start of layout", I'm not an expert in c2 so there may be a more efficient way of doing it but it should work at least. I use something similar.

Hope this helps.RockmanZero2012-08-04 23:42:25
B
25
S
161
G
3
Posts: 51
Reputation: 18,702

Post » Sun Aug 05, 2012 8:49 pm

RockmanZero, you helped me huge. Basically I'll have an event at the load of each layout that:

1- Checks where you came from.
2- sets player position according to that check
3- sets the new current level.

Thanks a tonne man!! Just wasnt thinking straight, not enough sleep or something. Your words were a vision of clarity. ;)
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
23
S
7
G
3
Posts: 375
Reputation: 4,797

Post » Sun Aug 05, 2012 9:37 pm

Worked a charm. Trying to think of how to make this easier in the long run but basically i set 3 variables:

playerX
playerY
playerFacing

And when the player collides with the 'levelchange' sprite, it sets the 3 variables to whatever they should be (playerX and playerY of the 'next' screen i'll be in, playerFacing = which direction they are looking, so if they come in from the right, it sets them to face left, etc)

Then on LayoutStart i basically set the player position to whatever the x/y are and set the Mirrored based on playerFacing. Bam!

Thanks again @RockmanZero
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
23
S
7
G
3
Posts: 375
Reputation: 4,797

Post » Sun Aug 05, 2012 11:41 pm

No probs glad you got it working 80bit.
B
25
S
161
G
3
Posts: 51
Reputation: 18,702


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Kagubro and 20 guests