How do I scroll the viewport on mouse near screen edge?

0 favourites
  • 4 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • So I can make a transparent sprite that the viewport always scrolls to and make some sprites on the edge of my project top, left, bottom, right that make the center sprite scroll too +/- 10 lets say and it works OK. But can someone point me in a direction of what function I should be using to make this more fluid? The current thing I'm using - on cursor over the "side" sprites is sluggish and probably wont work on every screen possibility.

    How can I detect the mouse hitting the screen edge and then scroll in that direction? Preferably at the angle its hitting. So 45 at corners and 90 in the dead center + all the iterations in between.

    Note I'm thinking the functionality seen in StarCraft and Civ - lots of games have this but I', not happy with my above mentioned solution.

    Don't waste time please just send me to the function I should be using VS sprite collision :)

  • I've never done it, but for a smooth camera movement I would track mouse.x/mouse.y and when they get to the edge (Compare X/Y vs the LayoutWidth/Height) and I'd scroll lerp to a new position.

    Also you can change the mouse cursor when it gets to the edge of the screen to show the player they are going to start moving the screen.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • like this..

    drive.google.com/file/d/1i7h9mL7QMHtcPqmn_k9FmIlFOVKH_-zb/view

    I have some overlap in my coordinates for moving.. so you should probably fix that otherwise it goes extra fast when you are in the corners...

  • Thanks Jobel,

    Got your version and the original working well. I found in full screen the performance is so much better (for both versions)

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