Make a scrolling menu...

Hi there :)

How can i make a scrolling menu with a lot of numbers? Like from 180 to 280 in a scrolling menu selection (same as native iOs)

Exemple here :
image

Thanks so much :)

Have a good day all!

Comments

  • sebmacflysebmacfly Member Posts: 1,018
    BUMP...

    No help? :)

    Im lost on that problem... Can't make it... Thanks
  • sebmacflysebmacfly Member Posts: 1,018
    I need this kind of input :

    image
    Like the date input.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Sorry - not enough info. What part are you asking about?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Pretty sure @sebmacfly wants to be able to tap on the "Wed Mar 16" in the second image and be able to swipe/drag that column of values up or down to select a different value.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    OK -- I'm not sure I've seen any examples on the forums for this. Here is one way (among possible others).

    First make the overlay. Its a separate bezel that has transparent holes where the numbers go. (Some nice shading helps as well.)

    Then make the numbers as a separate actor. (Which goes underneath the overlay/bezel.) You can make the numbers as a graphic or as a long list of numbers using the display text behavior.

    The numbers actor needs to be long and thin -- like a long strip of tape. It needs each separate number on its own line.

    The numbers actor would need to have behaviors that move it up and down as it is touched and dragged.

    So it is really just a long strip of numbers that move up and down (behind the bezel). The rolling/curvature feeling it gets is just an optical illusion.

    Is that what is being asked about?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I'm actually working on something similar for a word game I've developing. I spawned actors for the values (e.g. Wed March 16 would be an actor, Thur March 17 would be an actor), but I'm thinking there might be a way to use DisplayText or a single graphic and then base the selected value on the mouse position when released... thoughts? Since the selected value is always in the same Y location on the screen, I guess you'd subtract the graphic actor's Y value from it's starting Y value and then go from there.

    If anyone makes a demo (before me!) I'd love to see it.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    If the question is how to scroll and 'flick' the number actor (and then have it slow to a stop), here is one way:

    Make three attributes (type = real): myLinearVelocityY, oldY, offsetY

    Change Attribute: self.Physics.Drag To: 500

    When touch is pressed
    -- Change Attribute: self.offsetY To: ( game.Mouse.Position.Y - self.Position.Y )
    -- Timer Every .05 seconds
    ---- Change Attribute: self.Position.Y To: game.Mouse.Position.Y - self.offsetY
    ---- Change Attribute: self. myLinearVelocity To: max(-500,min(500,10*( self.Position.Y - self.oldY )))
    ---- Change Attribute: self.oldY To: self.Position.Y
    Otherwise
    -- Change Attribute self.Motion.Linear Velocity.Y To: self.myLinearVelocityY
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    And then for the snapback effect, I'm using this:

    Interpolate self.Position.Y to ceil(self.Position.Y/game.itemHeight)*game.itemHeight-game.itemHeigh/2

    So if each item in the graphic takes up 100 pixels (a list of 5 items would be an actor 500 high), it would interpolate self.Position.Y to ceil(self.Position.Y/100)*100-50. This seems to work well only if I position the actor so that self.Position.Y is a multiple of 50.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited November 2012
    To get it to stop completely and move to the right position:

    When
    self.Motion.Linear Velocity.Y < 100
    self.Motion.Linear Velocity.Y >-100
    -- Change Attribute: self.myLinearVelocityY To:0
    -- Change Attribute: self.Motion.Linear Velocity.Y To:self.myLinearVelocityY
    -- Interpolate Attribute: self.Position.Y To:(floor( self.Position.Y /21)*21)+7

    (Assuming that the text is 21 pixels high.)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Hmm... that's not working for me. I'll attach the demo I made with your rules (and a few of mine). You can toggle the Stop and Snap rules at the bottom (yours and mine).
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    We are both right! Your code works for snapping it at mouse-up (at slow speeds). Mine is for slowing it down and then snapping it into place.

    Turn them both on. (Also, change the actor's drag to 500.)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    The next challenge is to get the actor to loop back around to the start when it reaches its limit. I'd suggest something like:

    When self.Position.Y > 625
    -- Change Attribute: self.Position.Y To: 205
    -- Change Attribute: self.offsetY To:( game.Mouse.Position.Y - self.Position.Y )

    When self.Position.Y < 205
    -- Change Attribute: self.Position.Y To: 625
    -- Change Attribute: self.offsetY To:( game.Mouse.Position.Y - self.Position.Y )
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    We are both right! Your code works for snapping it at mouse-up (at slow speeds). Mine is for slowing it down and then snapping it into place.

    Turn them both on. (Also, change the actor's drag to 500.)
    Ah, I forgot to change the drag. Yep, that helps. It's working nicely now. Thanks for your suggestions!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Glad its working for you!
  • sebmacflysebmacfly Member Posts: 1,018
    Hi there! Thanks for reply!
    Interesting guys...
    I downloaded the project but the bar is scrolling and don't stop...

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @sebmacfly
    The project was not complete. In order to get it to stop scrolling you will need to add these behaviors:

    When self.Position.Y > 625
    -- Change Attribute: self.Position.Y To: 205
    -- Change Attribute: self.offsetY To:( game.Mouse.Position.Y - self.Position.Y )

    When self.Position.Y < 205
    -- Change Attribute: self.Position.Y To: 625
    -- Change Attribute: self.offsetY To:( game.Mouse.Position.Y - self.Position.Y )

    Perhaps @tatiang could be persuaded to upload a project with all the major parts working?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited November 2012
    Sure, here's the latest below.

    I actually had problems with the greater than 625 and less than 205 rules so I turned them off. But they are in the project file.

    I still notice some issues with quickly flicking or tapping the number bar at the wrong time... it causes the whole actor to fly up or down past the constraints. But mostly it works fine.
  • sebmacflysebmacfly Member Posts: 1,018
    Thanks so much guys! i'm looking this project :)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited November 2012
    @tatiang -- Thanks for posting a completed demo. You mentioned that there were issues with quickly flicking or tapping the number actor. If you turn on the >625 and <205 rules, that will eliminate most of that (if not all). The reason they do not work currently is because they are in conflict with a change attribute behavior inside the timer. You need to _turn_off_ the rule that says:
    Change Attribute: self.Position.Y To: min(630,max(210, game.Mouse.Position.Y-self.offsetY ))
    And you need to _turn_on_ the rule that says:
    Change Attribute: self.Position.Y To: game.Mouse.Position.Y-self.offsetY

    Also, it will look better if the top of the actor is padded with at least the last item in the list (an 8). And also pad the bottom of the actor with a copy of the first item (1). It will make the jump look smoother (actually seamless when everything is done right).

    This was a fun little project!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @sebmacfly -- glad you like the results. Hope it works for you!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Another update with @RThurman's changes made. I think the padding has to have a bunch of extra numbers, but I haven't done that yet. I think in a typical iPhone scroller, the numbers don't repeat; when you reach the top/bottom it just stops, but it's an interesting effect.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I was wrong about the scrolling. The images should repeat at the top and bottom to make it look like an endless scroll wheel.
Sign In or Register to comment.