mimicking scroll up and down of apple apps

With the text message app in ios phones, you can scroll up and the more you scroll, the slower the screen moves until it stops. When you release your finger it snaps back to it's original position. How can I achieve this in game salad?

Best Answer

  • RThurmanRThurman Posts: 2,879
    Accepted Answer

    @jsorr2 -- Curiosity go to me so I cobbled together three examples of making text scroll with the rubber band effect.

    The basic idea is to create two control structures that try to keep:
    1) the top of the text box near the top of the display
    2) the bottom of the text box near the bottom of the display

    And then to have a third control structure that tries to follow the mouse.

    The attached demo has three actors that do the same thing in slightly different ways.
    1)Actor one uses three move behaviors to get the job done.
    2)Actor two combines the three move behaviors into one move (with a huge equation).
    3)Actor three uses one constrain behavior (along with the huge equation).

    Three different ways to do it in GameSalad (but the same math).

    Here is the link:
    http://www.mediafire.com/download/gc1bgo80j9ijotj/kineticScrollingFinal.zip

    This was fun to make.
    Hope its useful!

Answers

  • jsorr2jsorr2 Member Posts: 279
    edited January 2015

    like this

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    This was Steve Jobs favorite patent! (#381) When he saw the effect he cancelled plans for an apple tablet and went straight for developing an apple phone instead. They called it "inertial scrolling."

    You probably want to search for "momentum scrolling" or "kinetic scrolling" or perhaps "rubber banding" effect.

  • SocksSocks London, UK.Member Posts: 12,822

    @RThurman said:
    jsorr2 -- Curiosity go to me . . .

    Brilliant stuff ! :)

  • jsorr2jsorr2 Member Posts: 279

    Will definitely check it out when i get home. Will edit this post when i do. Thanks for the efforts :)

  • SocksSocks London, UK.Member Posts: 12,822

    yeah, I thought it would be this . . .

    (max(0, game.Display Size.Height -( self.Position.Y +( self.Size.Height /2))) *10) -(max(0,( self.Position.Y - self.Size.Height /2)) *10)+ ( self.mouseDelta *1) *15

    . . . pretty obvious actually.

    :p

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @Socks -- Its not that bad! It basically boils down to:

    Velocity = DistanceFromDisplayTop - DistanceFromDisplayBottom + DistanceMouseMoved

  • SocksSocks London, UK.Member Posts: 12,822

    @RThurman said:
    Socks -- Its not that bad! It basically boils down to:

    Velocity = DistanceFromDisplayTop - DistanceFromDisplayBottom + DistanceMouseMoved

    Oh, I knew that's what it meant. :)

  • jsorr2jsorr2 Member Posts: 279

    I like the first option the best. Seems more fluid in my opinion. Thank you so much @RThurman‌. This will be so useful.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Glad it will work for you!

    I like the first way also. Its definitely easier to understand what is going on. And, I like the way that move behaviors are additive. But I was not sure of the efficiency of having three move behaviors. If (due to other elements in your game) the fps start to go down then you might need to switch to a method that only uses one constrain behavior. It might be more efficient than using three separate move behaviors.

  • sawkasteesawkastee Member Posts: 184

    Any way to group actors and use this scrolling method? I have a scene where actors are spawned dynamically based on the number of rows in a table. I'd like all the spawned actor (rows) to use this scrolling method. Thanks

  • jsorr2jsorr2 Member Posts: 279

    @sawkastee it would need to be in every actor manually. Of course you could just spawn duplicate actors with the code in it already.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited January 2015

    @sawkastee, I honestly haven't looked at the file attached above, but I did a scrolling menu in this thread:

    http://forums.gamesalad.com/discussion/75220/fast-constrain-linkmachine-v2

    That used @Socks 'fast constrain', maybe the two could be combined?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @beefy_clyro -- glad it will be useful for you!

    @sawkastee -- yes. But wouldn't it be easier (and more efficient) to have one text box and append the value of each table cell to a new row in the text block?

Sign In or Register to comment.