Level Change w/ Coordinates?

0 favourites
  • 5 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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. ;)

  • 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

  • No probs glad you got it working 80bit.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)