How do I scroll a layout with inertia?

Get help using Construct 2

Post » Sun Mar 26, 2017 4:41 pm

Hi guys,

is there a way to drag a layout with Mouse/Touch but also add inertia without adding a sprite with a ScrollTo behaviour?

I have no problem to drag the layout with the mouse/touch but can't find a way to add inertia if the Player scrolls his finger faster from dragging.

Thanks
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Sun Mar 26, 2017 6:02 pm

Here's an example you can pick apart:
https://www.dropbox.com/s/u96faamkmbb95 ... .capx?dl=0
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Sun Mar 26, 2017 8:33 pm

@R0J0hound
Thank you so much for your reply and time R0J0hound
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Sun Mar 26, 2017 9:41 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Mar 26, 2017 10:32 pm

@99Instances2Go

Thanks 99Instances2Go.
This is great guys for the help. This is exactly what I was trying to do.
I'm sure it will help a lot of more users.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Sun Mar 26, 2017 10:52 pm

@99Instances2Go

I dont want to bother you but I was looking for more info on the expression like Touch.SpeedAt(0) // Touch.SpeedForID(0) in order to understand the formulas and learn what they are doing.
Do you have a link where I can read this? When I search Touch or Touch.Speed , I dont find a link where they talk about those expressions?
Thanks
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Mon Mar 27, 2017 7:31 am

Manual is the place to start from.

The difference between Touch.SpeedAt(n) and Touch.SpeedForID(m) is the index presented by n.

When you touch screen, you can do this with more then 1 finger. The system makes a list of all those touches. An index is a place in a(ny) list. An index always starts at zer0. So, the first item in a list is always zero.

The n in Touch.SpeedAt(n) stands for the nth finger in the touch, or the index of a finger in the list.
The m in Touch.SpeedForID(m) stands for rather a special number.

When using the conditions 'On any touch start' or 'On any touch end' the expression ......
Touch.TouchID assigns a number to 'gesture' of the fingers that are on that moment on screen.

So, say you touch the screen with 1 finger, and a moment later with a second finger .... then ...

On any touch start
___________action ... 'set m to Touch.TouchID' will hold a number, and that will be different on the second touch.

Now you can use m in Touch.SpeedForID(m)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Mar 31, 2017 2:12 am

Thank you 99Instances2Go for the explanation. This is great and well explained. Cheers!!!
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Mon Apr 10, 2017 8:46 pm

Thank you both for your great examples! Very usefull ;)

I would like to create an infinite scrolling game. Any tips on how I could do that and not be stuck by the window size?

Thanks in advance!
B
6
S
1
Posts: 29
Reputation: 529

Post » Mon Apr 10, 2017 9:39 pm

@99Instances2Go
99Instances2Go wrote:1 more to pick apart.

https://www.dropbox.com/s/wmxnfqjlo3an0 ... .capx?dl=0

Very interesting !!
Could you do the same with 2 fingers for drag and zoom layer ? (One finger touch would be used to spawn an object on the scene)
Thanks !
B
33
S
14
G
5
Posts: 232
Reputation: 5,557

Next

Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi and 18 guests