Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Swipe to scroll / Inertial scrolling (example code that needs slight improvement)

Author
Message
Kevin Cross
21
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 1st Jun 2018 18:01 Edited at: 1st Jun 2018 18:11
I want to add flick to scroll to my non-gaming app and after searching the internet for example code on how to do this I've tried my best at replicating some of those confusing examples and thought others might want to use it.

I'm also sharing it because it's not 100% perfect and I'm hoping with the help from others it could be!

Unfortunately it's written for percentage based positioning and sizing as that's what I find easiest to work with but I'm sure it could be adapted easily enough to work with pixel based positions and sizes.

In this example I created 200 coloured sprites positioned one after the other to create a fake list type UI, and to give some content to scroll through. Change the noOfRows variable to increase or decrease the number of items.



Any suggestions on how to make it better so that the user wouldn't notice the difference between this flick to scroll and the flick to scroll they're used to in other apps like their browser app?

The larger flicks seem ok, especially changing this line if (timer() - previousTouchTime# > 0.2) to 0.25 or 0.3, but the small flicks could definitely do with some improvements. And it gets a bit flickery (visually) when near either end of the list.
Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 2nd Jun 2018 12:12
Interesting. I've been using this method. I wish there were a built-in function or a plug-in to make it easier.
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 3rd Jun 2018 01:47 Edited at: 3rd Jun 2018 05:46
Here's my take on a non percentage based solution. Attached a basic project to illustrate it.

Edit: Found a bug. Seems like on android it takes an extra frame to reset the pointer button commands.
Edit: Fixed.



Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-18 12:45:51
Your offset time is: 2024-11-18 12:45:51