How to Move/Scroll the layout camera

0 favourites
  • 4 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I had such a hard time to discover this that I decided to make a post the teach whoever needs it.

    In the forum, you may find some posts saying that you could create an object and put the scroll behaviour, make it invisible and then moving it.

    There's just one problem with this solution, when the object "camera" goes out of screen center, it take a moment to the camera start moving again since camera must return to the center of the screen to start moving. I found a much easier and elegant solution to this.(And you dont need the scroll behaviour)

    There is some actions called "set scrollX" and "set scroll Y" that sets the camera scroll coordinates. So you could create two global variables called "scrollY_var" and "scrollX_var" and then suppose that you want to move the camera to the right and left. You could do this:

    [On "d" key down] ""or any other trigger""

    -> Add 10 to scrollX_var ""change the number to change camera speed""

    -> Set scrollX to ScrollX_var

    [On "a" key down]

    -> Subtract 10 from scrollX_var

    -> Set scrollX to ScrollX_var

    Now you need to limit the "scrollX" value to not get over your layout and having delays in moving the camera. To do this, create this event:

    (To do this go to system -> compare variable)

    [If scrollX_var > layoutWidth - your layout width divided by 2]

    -> Set scrollX_var to scrollx (I don't know why to set to this, but it just works)

    [If scrollX_var < your layout width divided by 2]

    -> Set scrollX_var to scrollx

    And you can do the same thing for the de Y axis

  • You can do a great experiment.

    You can post this "с3p" file.

    And in half a year open it again, and if this code doesn't seem bad to you, then you haven't made any progress in half a year.

    I do that a lot when I open old projects.

    Happy New Year!

  • You can do a great experiment.

    You can post this "с3p" file.

    And in half a year open it again, and if this code doesn't seem bad to you, then you haven't made any progress in half a year.

    I do that a lot when I open old projects.

    Happy New Year!

    To be real, I already think is bad hahaha. But I still don't know how to make it better

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would share my solution, but I can't figure out what the problem is with the camera.

    Maybe there is some video or project file to see what you don't like?

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