How do I, keep two players on screen??

0 favourites
  • 8 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • I have two players and the layout is bigger of windows size.

    I want to see always the two players.

    How do I ?

    I tested "scroll to" in a two players, but is not a good solution becouse the players get out the screen.

    Maybe layout scale

  • Well the first solution that comes to mind for me comes from old restro games like bobble bobble where IF the one player gets outside the layout the other spawns behind him.... now if the two players are not working together then I'll come back after I test a few things out....

  • Thanks, but the spawn the second player is not good for my game.

    I test this:

    Player1 Scroll to

    Player 2 Scroll to

    even- Player 1 is on screen"invert" -- sclae layout 0.5

    Maybe it could work, but now,how ido scale 1.0 when player 1 and two are close

  • Scroll to the mid-point between the two players (+/- offset you want to make it easier to look ahead in one particular direction, for example), and then constrain the players to the visible area (simple rectangle clipping) so that they can't leave the screen

    Basically, you don't scroll to a player in particular ; you compute the area you want to frame, based on the position of the 2 players, and you prevent the players from going beyond that area

  • Scroll to a middle point between both players.

    Check the distance between players. If it's less than the screen width set the scale to 1. If it's greater than screen width scale it propportionaly (I wouldn't use a fixed 0.5).

  • Scroll to a middle point between both players.

    Check the distance between players. If it's less than the screen width set the scale to 1. If it's greater than screen width scale it propportionaly (I wouldn't use a fixed 0.5).

    Thanks

    Ok, but, how i do check distance betwen players??

  • Event: System -> Compare Two Values Distance(p1.X,p1.Y,p2.X,p2.Y) <= WindowWidth

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here it is....

    -system.. every tick

    -----System compare to variables

    -----------1000 / (distance (player1.X,player1.Y, player2.X,player2.Y)) > 1

    --------------------System set layer scale to 1

    -----System compare to variables

    -----------1000 / (distance (player1.X,player1.Y, player2.X,player2.Y)) < or = 1

    --------------------System set layer scale to 1000 / (distance (player1.X,player1.Y, player2.X,player2.Y))

    Also set both all players to have the scroll to behavior.

    You can make the 1000 any number you want as a min distance between players.

    This will scale the layer that the players are on to a percentage relative to the distance between them. If the percentage is 100% or more of the minimum distance the the scale will be 100% or in this cause just 1.

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