Scroll To Problem! Help Please :)

0 favourites
  • 6 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hi there!

    I don't want the player to be at the center of the screen. I want the player to be 1/4 of the screen when moving right and 3/4 of the screen when moving left. I have managed to do that but the problem is that is looks awful when the player is changing direction. I don't want the screen to "jump" straight to 1/4 of the screen to 3/4 of the screen and vice versa. I want the transition (right word?) to be smooth.

    Sorry for the lousy explanation but do you understand what I mean?

    What I mean when I say 1/4 of the screen and 3/4 of the screen is something like this. Imagine that "*" is the player and this is the screen [....]

    Moving right [.*..]

    Moving left [..*.]

    Thanks in advance,

    Tomolo Games

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What I mean when I say 1/4 of the screen and 3/4 of the screen is something like this. Imagine that "*" is the player and this is the screen [....]

    Moving right [.*..]

    Moving left [..*.]

    I would do it without ScrollTo, like that:

    You don't need a global variable. You can do it all in one line, but I think for explanation this is more readable.

    In 'On start of Layout' the size of the viewport will be calculated. Normally ViewportLeft will be 0 at the start, so the viewportSize would be equal to ViewportRight, but if you make this calculation after some scrolling or all calculation in one line it would be the wrong size. So this is more correct.

    In the events 2 and 3 you look if the x-position of the sprite is a quarter form the left viewport border or the right. If that's true it scrolls with the speed of the 8Direction-Behavior to left or right. In this case you will allways be a quarter from left or right border and you will never reach borders of the viewport.

  • Hey ,

    you could also try a lerp function:

    https://1drv.ms/u/s!Ap_-qxoGKbDcgQrbwBa06qwZood9

  • Thank you so much for your replies, I really appreciate it!

    However, it's not exactly what I had in mind. My own solutions gave me similar results as yours. I'm am looking for this:

    Any idea how I can achieve that in Construct 2?

  • I still recommend a lerp function. In order to achieve this inertia when changing direction of the player,

    I inserted an auxiliary variable. Maybe there is also a formula or a lerp in lerp function that I can not think of.

    Play a bit with the values in the lerp function to get the best result.

    https://1drv.ms/u/s!Ap_-qxoGKbDcgQxw8VytYkq7Qyyf

  • A thousand thanks for that one! It works great, awesome job!

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