How do I move the viewport when the player gets outside?

0 favourites
  • 10 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi all,

    Please, can you help me with the following problem?

    I have a layout which is 3072 pixels wide and 1920 pixels high. My viewport is 768 pixels wide and 480 pixels high.

    I placed my viewport in the left-bottom part of the screen with the following line:

    System --> On start of layout

    Action --> System: Scroll to (cintStartPosX_Laby01, cintStartPosY_Laby01)

    This moves the viewport to the location bottom-left.

    Now on the right I have an opening in my layout and when the player goes through that opening, the next room on the right has to move into the viewport.

    So I have the following event/action:

    sprPlayer --> Is out side layout

    Action --> -> System: Scroll to (cintStartPosX_Laby01-768, cintStartPosY_Laby01)

    cintStartPosX_Lab01 constant value is 0

    cintStartPosY_Lab01 constant value is 1920

    So I assume that this event will move the viewport to the other room on the right.

    However, nothing is happening.

    I searched but cannot find what I am looking for.

    Please, can you tell me how I can detect that my player is outside that opening and How can I move the viewport in a way that the first room slide to the left until the new room is fully in position?

    Thank you so much for your help, which I do appreciate.

    Chris

  • Hi again,

    Just a quick update.

    I experimented with adding the "Scroll to" behaviour to my player sprite. This moves the room into view when I move my player sprite.

    However, the new room has to be shown when the player sprite just steps outside the border of one room into the new room.

    At this moment, I do not know how to accomplish that.

    Somebody, any idea?

    Chris

  • I tried replicating what you described.

    dropbox.com/s/smg1mpj597yz8jo/ScrollViewport.c3p

    Is what you are trying to do something like that? Move the "Player" with the arrow keys, as soon as it leaves the visible area, it will scroll to the following chunk of the layout.

    Sorry about the graphics, I'm a software developer :P

  • Hi Diego,

    Thank you for your reply. I could not open your link yet, because this computer does not allow me.

    However, what you described is what I want. When the player goes through the opening, then the next full room comes into view (the former one is no longer visible). A new room always has to be a surprise for the first time user.

    Your input is much appreciated.

    Chris

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • there is an example project with room transition

  • Hi Frederiksthlm,

    Thank you for your reply.

    Please, can you give me the name of that example project? I searched for it but could not find it.

    Chris

  • Check these two

    • Hatch room transition
    • Dynamic camera system
  • Thank you so much, really appreciate it!

  • Hi all,

    I looked at the two example projects suggested above, but neither one does what I intend to do.

    On the exit of my room, I have a sprite "sprExit00_00_00", where the first two "00" stands for the room number, the second two for the X position number and the last two for the Y position number. This sprite is invisible.

    I add an event to that sprite:

    sprExit_00_00_00

    On collision with sprPlayer

    Action:

    -> System: Set scroll X to cintStartPosX_Laby01+cintViewPortShift_X

    The viewport is 768 pixels wide, and the value of cintViewPortShift_X is 1152.

    I do not understand why the viewport shift is 1152 instead of 768 which is the actual width of the viewport and layout.

    I have about 120 rooms in my game, with at least 2 exits but also 4 are possible. So I will have more than 300 sprites in my layouts, which handle the transition process of the room.

    Also, when the player is in one room, he is not allowed to see the next room until he goes through the openings.

    Despite the fact those exit sprites work, I think this is not a good way of doing this.

    Please, can you give me some advice or a method of how I can switch rooms without giving the next room away until the player touched the invisible exit sprite?

    Thank you so much for your help which is appreciated.

    Chris

  • Hi all,

    I am rethinking the structure of the game. Instead of having one big layout which contains 120 rooms, I am planning to create 120 layouts. Each layout contains one room.

    To switch rooms, I use one invisible sprite and an instance variable which contain the name of the layout switching to.

    It seems more difficult than I originally expected. When I write this in code, it will be much easier to accomplish.

    Chris

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