How do I smooth scroll from one object to another?

0 favourites
  • 5 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)

  • 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

  • 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)

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

    Dan

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