How do I scroll window view left and right

0 favourites
  • 10 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I have a layout that is 1920x480 and a window size of 640x480 for three total views.

    I want to be able to swipe from left/right to go to each view.

    Is there a built-in way to do this?

    Right now I have a sprite with scroll-to behavior and on each swipe or left/right button click I set the angle and bullet speed and have it move to the next view.

  • Helper sprites are always useful and usually the quickest, simplest solutions.

    For a event only version, you would be saving the Touch position to a variable On Touch, and comparing that to the current Touch.X position. With the condition Is In Touch, you can use Scroll to X where X is the difference between scrollx (current screen position) and Touch.X-OriginalTouch.X (length of drag). Depending on where scrollx ends up closest to, you can then set the Scroll to X to the appropriate screen On Touch Released. To get things smooth, lerp can be used as well.

    But yeah I would definitely recommend just sticking with a helper sprite as long as you are satisfied with the result.

  • Thanks oosyrag

    How do you get the screen to 'snap' to the new view?

    Like if you only swipe across just over halfway, it will go ahead and finish and snap to the new view.

  • It looks like I'm getting better results using LiteTween when I press L/R buttons, very smooth and eases in/out

    I would love to see a touch swiping example, though

  • 3DPiper

    I did a tutorial about a touch swiping system a long time ago - I have been meaning to go back and see if I would do things differently now, because I have learned a lot in the last year.

    Take a look, it may help... (look at the swipe2 version): https://www.scirra.com/tutorials/726/swipe-to-change-page

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • AllanR,

    Your swipe2 version is sweet! I'd love to see how you did that, very smooth.

    This should be built into C2

  • well, you can download the capx from the tutorial page (near the top, on the left) swipe2.capx

  • AllanR Hi Allan. Brilliant design! I actually bought something similar on this site that was much too complicated. Your swipe design is smooth and simple. One question; Do you have any idea how to get a tab on top to show on all of the layouts without scrolling with the tiles? I was thinking something similar to whatsapp with the CALLS CHATS AND CONTACT tabs. Lastly, do you have like a donate page where people who use your design can donate funds?

  • Emac

    the swipe2.capx file has a HUD layer (with nothing on it). To make that layer stay on screen all the time, set its parallax settings to 0,0

    then you can add a tab with icons on that layer and they will stay put. (put the tab on the left side of the layout - otherwise it probably wont be on-screen)

    No, I don't have any way for people to donate, but thanks for the offer! Most of what I have learned about C2 is from helping people in the forums solve problems - so it is already a win/win situation...

  • AllanR - Wow! Works like a charm! You're an excellent instructor. Thank you so much and you need to do more tutorials. You're a natural teacher. Thanks again!

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