Slow Scrolling

Get help using Construct 2

Post » Sun Apr 16, 2017 6:58 pm

hi there im having a bit of a brain block atm. i want to be able to click an object and the window would slowly scroll to it not instant like scroll to behavior, but i cant work out a way without it colliding with my scrolling code
which is this https://www.scirra.com/tutorials/415/dr ... uch/page-3

please help
B
19
S
6
Posts: 143
Reputation: 1,835

Post » Sun Apr 16, 2017 9:02 pm

use lerp and remove scroll To behavior. Add 2 variable to register mouse click position like clickX & clickY.

Set scroll:
for x > lerp(scrollX, clickX, 0.1)
for y > lerp(scrollY, clickY, 0.1)
ImageImage
B
115
S
51
G
24
Posts: 790
Reputation: 23,505

Post » Sun Apr 16, 2017 9:09 pm

one way this can be done is to make an invisible object that the windows follows like cross-hairs in a FPS. then instead of scrolling you would have a the "cross-hairs" move to the object. I have done this in one of my WIPs and it works great.

I'm also looking into more formal ways.
B
16
S
7
G
5
Posts: 30
Reputation: 3,777

Post » Sun Apr 16, 2017 9:12 pm

alextro wrote:use lerp and remove scroll To behavior. Add 2 variable to register mouse click position like clickX & clickY.

Set scroll:
for x > lerp(scrollX, clickX, 0.1)
for y > lerp(scrollY, clickY, 0.1)


Well I guess I don't have to look for a formal way, thanks for sharing this.
B
16
S
7
G
5
Posts: 30
Reputation: 3,777

Post » Sun Apr 16, 2017 11:28 pm

thanks for the replies guys :), i did look at lerp but wasent sure how to use it with scroll function :)
B
19
S
6
Posts: 143
Reputation: 1,835

Post » Mon Apr 17, 2017 1:24 am

http://imgur.com/a/rbUK2

heres a screenshot of the code, its not working, i can see why its not working but im not sure how to fix it in the way you said
B
19
S
6
Posts: 143
Reputation: 1,835

Post » Mon Apr 17, 2017 2:22 am

@darkrealos

the Every Tick sub event will only run on the tick when the mouse click event fires. You need to have it be a top level event. Set clickx and clicky to scrollx and scrolly at the start of layout so that it doesn't move the camera location until you click to make it move.
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Mon Apr 17, 2017 2:31 am

im sorry im not really following, i understand the every tick event wont work, kinda new that before hand should of removed :(, but im not sure whot to do the every tick event without it colliding with the scroll event

p.s. i dont completely understand the scrolling mouse code which makes it harder for me
B
19
S
6
Posts: 143
Reputation: 1,835

Post » Mon Apr 17, 2017 3:10 am

thanks for everyone replies and help. ive managed to work it out with what you all said :)
B
19
S
6
Posts: 143
Reputation: 1,835

Post » Mon Apr 17, 2017 8:54 am

Mind sharing your solution?
B
15
S
7
Posts: 244
Reputation: 2,065


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests