How do I scroll window view left and right

Get help using Construct 2

Post » Tue Jun 28, 2016 4:37 pm

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.
B
29
S
14
G
9
Posts: 80
Reputation: 6,003

Post » Tue Jun 28, 2016 4:54 pm

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. ;)
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Tue Jun 28, 2016 9:11 pm

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.
B
29
S
14
G
9
Posts: 80
Reputation: 6,003

Post » Tue Jun 28, 2016 9:54 pm

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
B
29
S
14
G
9
Posts: 80
Reputation: 6,003

Post » Tue Jun 28, 2016 10:20 pm

@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
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Wed Jun 29, 2016 3:43 am

AllanR,

Your swipe2 version is sweet! I'd love to see how you did that, very smooth.
This should be built into C2
B
29
S
14
G
9
Posts: 80
Reputation: 6,003

Post » Wed Jun 29, 2016 4:28 am

well, you can download the capx from the tutorial page (near the top, on the left) swipe2.capx
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Fri Jul 01, 2016 1:32 am

@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?
B
15
S
2
Posts: 28
Reputation: 1,231

Post » Fri Jul 01, 2016 2:11 am

@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...
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Fri Jul 01, 2016 1:51 pm

@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!
B
15
S
2
Posts: 28
Reputation: 1,231


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 21 guests