How to create a looping list?

Hi Guys,

Thought I'd reach out to this fabulous bunch again :)

Basically what I want is a scrolling list that loops through but implements either up or down.

e.g.

100 items in a table.
10 show on the iPhone.
When you scroll up, the initial actor loops round but displays the 11th item, the 2nd scrolls round to the 12th item, etc etc
This then works in the same way scrolling the opposite way to head back towards the original 10 displayed items.

This way I only keep minimum actors on screen and the text would be pulled from the table according to its position and what loop it is in.

Thanks,
Keith

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Oooh. Sounds fun. I'll see if I have time to try my hand at a demo. :D

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    @Braydon_SFX said:
    Oooh. Sounds fun. I'll see if I have time to try my hand at a demo. :D

    @Braydon_SFX‌ Thanks bud, would be much appreciated if you get something :)

  • ashtmjashtmj Member, PRO Posts: 405

    do you mean a scrollable shop list like this?

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @ashtmj‌ - I think he means a vertical list - scrolling up and down with your finger like you would on a webpage. @beefy_clyro‌ - I have an idea on how to do this, but time is not permitting me to do it right now. I'll see if tomorrow or later this week I can work something up.

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    @Braydon_SFX said:
    ashtmj‌ - I think he means a vertical list - scrolling up and down with your finger like you would on a webpage. beefy_clyro‌ - I have an idea on how to do this, but time is not permitting me to do it right now. I'll see if tomorrow or later this week I can work something up.

    Thanks Ash, thats was one way I thought about doing it but i'd prefer to get the way that Braydon has mentioned.
    It would do what yours does but you swipe up or down and the list would change accordingly to what one had gone off screen.

  • ashtmjashtmj Member, PRO Posts: 405

    ahhh...like so?

    This is still using the shop I made in the vid.
    All I did here was make one new actor with a few attributes.

    core Y (real)
    offset Y (real)
    Index # (index)

    Change self.coreY to self. position Y

    Constrain self.offset Y to self.core Y - self. position Y

    Constrain self.index# to floor(self.offsetY)/20

    Constrain game.row# to self.index#

    so every 20 pixels the "scroll" actor moves it moves down the list 1 row.

    you need to fine tune the scrolling actor to account for the touch offset, etc.
    but all in all it works pretty well without much code at all

    thats all I have..it's all up to @Braydon_SFX now :)

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

    Here is another take (along the same theme as @ashtmj‌). Perhaps it will spark an idea.

  • ashtmjashtmj Member, PRO Posts: 405

    @RThurman thats awesome! and better then mine as you are working just off the touch position rather then a actor. It inspired me to add one extra detail, another actor that adds a "drift effect" rather then stoping right after the player lets go :)

    https://www.dropbox.com/s/jz4v32p00cf3jip/LoopingTableDisplay_V1-2.zip?dl=0

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    @RThurman - Thats great, thanks!
    @ashtmj - Like the addition of giving the smoothing effect. Wouldn't work so well in my case as those displayed lists i want to make clickable, as the scroll works off touch count, as soon as you touch one on the list, the list has already begun to move.

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    @RThurman‌ @ashtmj‌ I've been playing with this tonight and its pretty much spot on for what I want. Thanks for taking the time to demo it, I was never thinking of a solution along these lines :)
    Is there a way of slowing down the scroll? Currently, a slight move up or down ramps through the entries very quickly, i want them to have to swipe a further amount for it to change display.

    Cheers

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

    @ashtmj‌ -- Nice! I like the "drift effect"!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited October 2014

    @beefy_clyro said:
    RThurman‌ ashtmj‌ I've been playing with this tonight and its pretty much spot on for what I want. Thanks for taking the time to demo it, I was never thinking of a solution along these lines :)
    Is there a way of slowing down the scroll? Currently, a slight move up or down ramps through the entries very quickly, i want them to have to swipe a further amount for it to change display.

    Cheers

    Yes, there is always a way to slow the movement down. For example, you could divide the yDistance being calculated:

    Constrain Attribute: self.yDistance To: ( game.Mouse.Position.Y - self.yMouseStartPos )/3

    Just curious -- are you trying to build a Picker View with a tables? Something like this?

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    @RThurman‌

    Awesome, thanks!

    I wasn't trying to do that, no ... although it would be very useful for that without much adaption.
    A few times now I have been working on apps (that have never seen the light of day) which involves tables that will be displayed to the user, sometimes this has been fixed, others, if coming from another server, can be varying in length.
    I implemented a horrible system first time round that basically calculated how many were in the table and spawned the placeholders to match, the tables were always relatively small so I know it would work but also knew it was a horrible system! I never quite got my head round something like this, so simple, yet so elegant and caters for small or big tables and is light on actors.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I though @StormyStudio‌ did a menu like you're looking for? I remember him posting it.

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

    @The_Gamesalad_Guru said:
    I though StormyStudio‌ did a menu like you're looking for? I remember him posting it.

    Good point! Here is the link to Stormy's thread:
    http://forums.gamesalad.com/discussion/63466/stormys-gs-table-izer-free-template-tool-to-preview-and-scroll-through-tables-for-easier-testing

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @RThurman‌ this is the one I was talking about. He was working on it as part of his server multiplayer tests. Maybe beefy could email him for the code.

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    Ah yes that was the kind of thing and I forgot about Jon making that! I'd love to see how it was done, what RThurman has given me will work for what I need though for sure.

    Cheers

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

    @The_Gamesalad_Guru said:
    RThurman‌ this is the one I was talking about. He was working on it as part of his server multiplayer tests. Maybe beefy could email him for the code.

    Yes... that is a nice effect! I must have forgotten about that one. Thanks for the reminder.

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

    Here is yet another version. It has better control of the speed and is simpler (using only one actor for everything).

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    Nicely done :)

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Wow, nicely done guys! Excellent solutions! Sorry I didn't get around to it, @beefy_clyro‌, but it looks like the files @RThurman‌ and @ashtmj‌ provided are top notch!

    @RThurman‌ and @ashtmj‌ - Guys, why aren't these in the spare code thread yet?!

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

    @beefy_clyro said:
    Nicely done :)

    Thanks I hope it comes in handy for you.

    @Braydon_SFX said:
    RThurman‌ and ashtmj‌ - Guys, why aren't these in the spare code thread yet?!

    Thanks Braydon, I will need to clean it up a bit. Then I'll put it into the spare code thread.

  • beefy_clyrobeefy_clyro Member Posts: 5,394

    No worries @Braydon_SFX‌
    These should def go in Spare code thread :)

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    Does this work with images/actors and not just text??

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @AsOfLatte Anything that works with text will also work with images since you can use text in a Change/Constrain Attribute self.Image expression.

Sign In or Register to comment.