0 Favourites

Defining player position while switching layouts\screens

This forum is currently in read-only mode.
  • Hi, hope to get an answer to a problem:

    I'm doing top down adventure game, where each screen is a separate layout, surrounded by 4 collision objects that:

    1. on collision with player set a global variable (1 - up,2 - right,3 - down,4 - left)

    2. on collision with player depending on the side player exits screen sets global var Player_X or Player_Y

    3. after setting these - it loads corresponding layout

    Each layout has a "On load" event, where global variable (side) is checked depending on it's value the X and Y position of a player should be set.

    And this partially true - the part that sets player position to (Player_X or Player_Y) operates normally but the part where position is defined in absolute values is ignored, instead the position of object on the layout is used (I place player on each layout).

    How can i make it work? Or maybe you see whats wrong with the game logic here.

    Thanks

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Is the problem that the player exits right but still appears on the right side of the screen in the next layout? I'm not sure I understand.

    Just a recommendation: if the game is gonna have a lot of "screens" to play on, make one layout for each area (like, forest), and make the game scroll "per-screen" (and make the layout as big as the amount of screens you want). One way to do this could be:

    Center X scroll to -> Floor(Player.X/game's resolution width)*game's resolution width + half of game's resolution width

    There might be a different calculation for it (to do it with scroll Y, just replace "X" with "Y" and "width" with "height". I think that this will make working with your game file faster and easier in the long run,

  • The problem is that if I exit the screen in it's lower part, I expect character to appear on the next screen on the same X he exited previous and with the Y=45 (to appear in the upper part of the screen with some offset). It does occure but the Y part is taken as it is for the character on the second screen.

    concerning your recomendation: it is quite helpful though what i'm trying to achieve is the connection of screens that wouldn't be linear, so in some cases walking left from screen A leads to screen B and in other cases it leads to C or Z. So it seems that i can't use the scheme you're proposing, thanks anyway.

  • The cap file in this thread might help:

    It uses spawn points to create the player at different points.

  • it doesn't work in my case.

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