How to create a looping list?
beefy_clyro
Member Posts: 5,394
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
Oooh. Sounds fun. I'll see if I have time to try my hand at a demo.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
@Braydon_SFX Thanks bud, would be much appreciated if you get something
do you mean a scrollable shop list like this?
@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.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
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.
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
Here is another take (along the same theme as @ashtmj). Perhaps it will spark an idea.
@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
@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.
@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
@ashtmj -- Nice! I like the "drift effect"!
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?
@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.
I though @StormyStudio did a menu like you're looking for? I remember him posting it.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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
@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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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
Yes... that is a nice effect! I must have forgotten about that one. Thanks for the reminder.
Here is yet another version. It has better control of the speed and is simpler (using only one actor for everything).
Nicely done
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?!
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Thanks I hope it comes in handy for you.
Thanks Braydon, I will need to clean it up a bit. Then I'll put it into the spare code thread.
No worries @Braydon_SFX
These should def go in Spare code thread
Does this work with images/actors and not just text??
@AsOfLatte Anything that works with text will also work with images since you can use text in a Change/Constrain Attribute self.Image expression.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User