How do I smooth scroll from one object to another?

Get help using Construct 2

Post » Thu Apr 17, 2014 2:53 pm

Hi guys,

Is there an easy way to scroll from one object to another? Like I want it so when the game loads, it focuses on object 1, and after 3 seconds it scrolls smoothly to object 2.

Any help appreciated.

Thanks,
Dan
B
8
S
1
Posts: 65
Reputation: 1,108

Post » Thu Apr 17, 2014 7:25 pm

You could scroll to "lerp". Lerp(A, B, C) <---- lerp uses 3 parameters,
A = start point, B = goal, C = a number that must range from 0 to 1.

you must use a variation of this for X and for Y in scroll to. so you need 5 variables.

var1= where scroll.X is now (A)
Var2= where scroll.Y is now (A2)
Var3= where you want scroll.X to go (B)
var4= where you want scroll.y to go (B2)
var5= the movement. (starts in 1)

You'll need to change those variables around as you scroll from one object to the next.
example. you want to scroll from object 1 to object 2:

- every 0.01 seconds, as long as var5 is less than 1; add 0.1 to var5 (how fast you add to var 5 determines the speed of the scroll)

- on a trigger: (on scroll to, you'll see you need to insert X and Y parameters) (if you know how to uses functions this would be super easy)
set A to object1.X
set A2 to object1.Y
set B to object2.X
and B2 to obejct2.Y
set var5 to 0

this would actually look like Scroll to X: lerp(A,B,var5); scroll to Y: lerp(A2,B2,var5)

let me know if you get it from this, i could later on today make you an actual Capx with all this working ^^ (and please don't be lazy and really try to understand what i wrote)
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Thu Apr 17, 2014 8:00 pm

Ohh I'm not very technical when it comes to stuff like this. I kinda get it but I wouldn't really know how to implement it. I'm ok with changing, adapting code but that's about it haha! Thanks for your help anyway, I'm gonna give it a shot.

Thanks,
Dan
B
8
S
1
Posts: 65
Reputation: 1,108

Post » Fri Apr 18, 2014 10:42 pm

My way is using a hidden sprite with ScrollTo Behaviour. Now when you want to scroll, just make an event like

On every 0.1 seconds
->Hidden Sprite Move Forward 1 Pixel (this is just an example, here you should put your logic to move to your desire position)

It's useful when you have a main character with ScrollTo behaviour but you want to focus to another element for just a moment. In this case you don't need to disable the scrollTo of the main character, just unpin the HiddenSprite from the main character an move it to whenever you want (here you can use the lerp technique of @Sargas)
B
10
S
2
G
1
Posts: 48
Reputation: 1,265

Post » Sat Apr 19, 2014 12:16 am

That's a great idea Jeeba. I think I'll do it that way. Thanks! :)

Dan
B
8
S
1
Posts: 65
Reputation: 1,108


Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, jatin1726, Kyatric and 30 guests