Solved: Manage scroll behavior (Metal slug like)

0 favourites
  • 10 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Edit : Solved :)

    Thx to Kyatric Demo in this thread


    I would like the Horizontal scrolling only to move forward and to bound on the left part!

    My game test : (Edit: now working)

    Here is what I already thought :

    I only needs the scroll when my player moves forward so here we are:

    * Player is playing animation Right > System Scroll to player.x

    It works but as soon as I press right the Player is back in the middle of the screen.

    It would work if I could use Windows coordinates.

    Like if Player playing animation right + is in the middle (or Window X coordinate) then System scroll to player.X

    Like that When I go back it doesn't scroll and it starts scrolling only when I reach the middle of the window for example!

    Also window coordinates could be helpful To bound the player.

    Because right now if I go back , the player may not be on screen but he is still on the layout and I can't make it bound.

    I could do it if I could just set an invisible Sprite on Left border of the window.

    So am I going all wrong with that ?

    What could do the magic ? Is there any Window coordinate to use ?


  • What you can do is compare the X position of your character to X of the window (viewport) / 2.

    With this logic, if the X position of your character is greater or equal half of the X viewport, he'll be on the right, so set the camera to follow. If his X position is lower than half of the X of the viewport, he'll be on the left, so set the camera to stop following.

    Good luck!

  • Thx andreyin for answering

    What expression should I use ? Is it for Construct 2 ?

    I can't find any window.x or viewport ! and also nothing about a camera !

    Any help on that ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is an implementation of what Andreyin said :


    The capx is commented, and all is made so that modifying the dimensions of the player sprite or of the layout or even of the window automaticly works.

    It is just an implementation. You'll surely have to adapt it to your project.

  • Thank you Kyatric,

    This is indeed very useful , I think you just solved my problem ! :)

    Thx again I will try to adapt it asap !

  • Hi again !

    I tried to start scrolling at 30% of the windowwidth but no matter what I change to Kyatric example, it still scroll from the middle.

    As a consequence I solved this by adding an invisible sprite at X distance from the player.X

    Is there a way to do it without an invisible sprite ? or is it the good solution ?

    Example (modification of Kyatric capx):

    Just copy paste the link in your brower can't make it work on the forum directly

  • Event 4

    You could make something like

    Player.X >= Scroll.X - 200 -> set scroll.x to Player.X + 200

    I feel 200 is not a good measure, but you can affine from there.

  • Hi,

    So here is a follow up !

    So far in Metalslug like games we can't go back and we scroll the player not from the middle ! And thx to Kyatric this now happening.

    In Metal slug very often the camera stop until the hero kills all ennemies. When it's done there is a smooth camera movement which set again the player at 40% of the screen.

    I had difficulties to find out how to have this smooth camera movement but I did something which is very close to that! At least I hope.

    So let me know if i am right: basically I change Kyatric formula and used lerp to have a smooth scrolling effect after killing all ennemies.

    My example file: Example file

    You need to jump on the sprite 500 (ennemy) to kill him and see the effect i was looking for

  • Metal slug is a good example, not in center of char.

    I put a camera invisible char and I follow it. This moves only in X

  • Hi everybody,

    I want to do a metal slug like and i was very happy to find this topic with this capx.

    But i need that the camera follow the player in Y if the player reach the middle of the screen. I past three days on it but i didn't do anything usefull... Can you help me ?

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