Any way to simulate scroll-to "shake"?

0 favourites
  • 11 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Any way to do this? I am doing my scrolling manually, and I miss this cool feature.

  • Always

    -Set Scrollx to Player.x+Player.shake

    -Set Scrolly to Player.y+Player.shake

    +Player.shaketime>0

    -Subtract 60*dt from Player.shaketime

    -Set Player.shake to -10+random(20)

    +Something happens

    -Set Player.shaketime to 10 or something

    Could use some tweaking to have the shake get weaker over time or be more consistent, but this should do!

  • Tokinsom, that has a problem... you can end off getting way off where the scroll is supposed to be, as the next value is generated from the adjusted value...

  • +Player.shaketime <= 0

    +Trigger once

    -Set Player.shake to 0

    You just have to get rid of the offset that Player.shake causes when the shake ends.

  • Yeah, but if I want the shake to go for an extended period of time...

  • What does that have to do with it? During the shake the scroll offset can only go from -10 to 10, and will stay anywhere in-between until shaketime hits 0. When that happens everything should be reset, setting the scroll position back to the player.

  • if you do a

    set scroll to lerp(scroll,player,dt)[/code:29x80mzq]
    
    just use a variable as intermediate.
    [code:29x80mzq]set scrollVar to lerp(scrollVar,player,dt)
    set scroll to scrollVar[/code:29x80mzq]
    
    Then you can easily add any noise you want on that
    [code:29x80mzq]set scrollVar to lerp(scrollVar,player,dt)
    set scroll to scrollVar + random(-20,20)[/code:29x80mzq]
    
    (note: I didn't split things into X and Y... I'll let you do that )
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yann sqiddster

    Can someone explain how this works please in a bit more detail. <img src="smileys/smiley1.gif" border="0" align="middle" />

    This is my Camera settings to shake.

    Every Tick > Sroll to position > X: PlayerBox.X

                            Y: lerp(PlayerBox.Y - WindowHeight /6.0, ScrollY, 0.5)

    Layout size: 1.5

    or up a .capx that would be sweet.

  • OK I figured it out

    Global Variable: ShakeVar: 0

    Shake by N7Effect, on Flickr

    Ex: every 0.001/(Everytick) seconds: Animation playing "Shoot"

    Kyatric

    Frequently asked Section

  • o.o people use flickr for construct2 0.0 keep going people nice idea :P

  • I'm looking into this, I have custom scrolling, and I tried the Shift effect and my own custom... I don't like how it looks.. I need something that will "reduce in magnitude" with some sort of easing like a lerp or something...

    Currently I have:

    Set ShakeAmount to ShakeCountdown * (MaxShakeAmount / ShakeDuration)

    ScrollTo position lerp(scrollx,sprite.X + (random(ShakeAmount+(ShakeAmount*2),ShakeAmount)),0.05) //and do the same for Y

    sorry I know this is an old thread, just wondered if anyone ever figured a good way with custom scrolling...

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