Scrolling Demo

This forum is currently in read-only mode.
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • So I was thinking, "I want a map layout that I can scroll around". Soon I realized that just "Scroll to MouseXY" just won't do, as it instantly focuses the screen on mouse coordinates.

    After a bit of reinventing the wheel, I've come up with a smooth layout scrolling solution. See the attached cap. Just hold left mouse button to scroll around.

    I dare you to find a more elegant solution! All is fair in love, war and development.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome, one event too!

  • ScrollX-distance(MouseX,MouseY,ScrollX,ScrollY)/32*cos(angle(MouseX, MouseY, ScrollX, ScrollY))

    I'm sure that can be simplified...

  • It can be simplified to just:

    lerp(ScrollX,MouseX,0.03)

    lerp(ScrollY,MouseY,0.03)

    The 0.03 affects the speed...0.03 is about 1/32...

  • Hm, I feel so silly now that I look at it with rested brains. I should just have taken the difference between ScrollX and MouseX then substract it from the ScrollX!

    ScrollX-(ScrollX-MouseX)*0.03 (horizontal scrolling speed)

    ScrollY-(ScrollY-MouseY)*0.04 (vertical scrolling speed)

    Since I can't seem to edit my initial post, I'll just upload the updated cap here.

    Edit: Oh, so that is what lerp does!

  • Yep Never the less, its a nice way to scroll around, anyone making their own level editors should use that event rather than trying to create scrollbars or something (which is harder to make, and less intuative to use)

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