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 / [SOLVED] Scrolling Issue

Author
Message
frosty45
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location:
Posted: 4th Jul 2018 00:50
I am going nuts here. I have been trying to figure this problem out for far too long. Maybe you guys can help.

I am writing a program that has these different sessions on the screen that you c an scroll through. I have coded the "glide" when scrolling so that when the finger is released the menu keeps scrolling but slows down. It works fine testing it on PC. The yMove variable decreases at the perfect pace. When I broadcast or install on any other device(tested on iOS and Android), the gliding ceases to work. The yMove variable goes to 0 very quickly. I don't know why the behavior is different between platforms.

I've attached the project and also pasted the problem code here:

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

frosty45
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location:
Posted: 4th Jul 2018 01:27
Ok...so slowing the code down in GetPointerState() = 1 seems to "fix" it...



n = 2 seems to be the magic number.

I guess the issue is that on a screen yMove doesn't get as big on a device as it does on PC? That or the processing rate is much faster on a device than the PC . I am running a Ryzen 1700 though.
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 4th Jul 2018 19:18 Edited at: 4th Jul 2018 19:20
You didn't specify a Sync Rate.
This code will run at different speeds, depending on the screen refresh rate of the device.

You can either set a custom sync rate, or you could do some framerate-independent coding based on time.

Have a look at


PSY LABS Games
Coders don't die, they just gosub without return
frosty45
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location:
Posted: 4th Jul 2018 20:38
I had one specified originally. It's provided by default on new projects. I had taken it out trying to figure out the issue. Unfortunately, the sync rate doesn't change anything.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Jul 2018 21:03 Edited at: 4th Jul 2018 21:49
are you trying to do something like this

Scrolling Menu
fubar
frosty45
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location:
Posted: 4th Jul 2018 21:34
Yes something like that. I'd rather use the view offset though rather than changing the position of each individual sprite and textboxes on the screen.

What I can't figure out is why my yMove variable is 0 as soon as the pointer is released when running on a device.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Jul 2018 22:07
not sure I haven't tried moving the viewoffset with the mouse before but I have moved the offset with keys
with my platform editor https://forum.thegamecreators.com/thread/219932

you may need to make use of the screentoworld commands
from the help file on screentoworldX





fubar
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 4th Jul 2018 22:15
For some reason on android the "GetPointer" commands don't reset on the next frame. You have to skip the next frame and it will work correctly. Essentially they return true for 2 consecutive frames instead of one. At least that was my issue. Also, I don't know if this issue is with other commands and I don't know if this is a bug or how Android is supposed to work.
frosty45
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location:
Posted: 4th Jul 2018 22:36
IronManhood, that makes a lot of sense. What you're saying is the GetPointerState remains true for a frame after releasing, thus the getpointery and the saved last Y position are the same making it 0 when subtracting them from one another.

Thank you!

Fubarpk is this something you can verify and maybe fix down the road? This issue is also on iOS devices.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Jul 2018 23:28
It should remain the value until next sync() call
fubar
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 4th Jul 2018 23:55 Edited at: 4th Jul 2018 23:58
Ok, maybe the pointer commands aren't the problem.


IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 5th Jul 2018 00:51 Edited at: 5th Jul 2018 01:49
Alright, why would this code for scrolling the viewoffset work correctly on the windows but not on android?

<code snippet removed>
frosty45
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location:
Posted: 5th Jul 2018 00:57 Edited at: 5th Jul 2018 01:13
This is more in line with what I'm trying to achieve. The clicking is resetting the viewOffset (don't have time to figure that out) but it still glides on PC, but not on Android. Sorry, I took out the sleep and turned off the syncrate.

Edit: Your last code....exactly the issue! I have no idea! You can make the values to change the offset insanely high and they'll be zero when you release the pointer. I think like you said, it takes android an extra frame to detect the pointer release. I gotta prep for 7/4. Thank you for looking into this with me

IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 5th Jul 2018 01:35 Edited at: 5th Jul 2018 01:48
Actually, I think I've figured it out. When you release the pointer on windows the mouse continues to move which continues to change the pointer position which makes the the pointer position delta NOT be 0. On Android, when you "release" the pointer you are no longer touching the screen which no longer changes the pointer position. Therefore, the pointer delta is updated to 0 because the pointer hasn't moved since the last frame. This isn't a bug at all. Just a difference between devices. To remedy this, just make a second delta and set it equal to delta that will be updated this frame. Make sure the second delta is updated before the current delta.

frosty45
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location:
Posted: 5th Jul 2018 05:47 Edited at: 5th Jul 2018 05:53
This post has been marked by the post author as the answer.
Alright. Thank you so much for your help and time. Here's what I did to find out the best last pointerY to use. I added an array and while the pointer is pressed the current Y is saved to the array. If the array is greater than 5 in length then the first array entry gets removed. When the pointer is released, yMove is recalculated to the Y at any position you'd like. The further back you go in the array, the move "glide" effect you get. I've found the 3rd is just about right. So not the previous Y, but the one before that. In the app that I'm working on it works perfectly. In the test code below, it's similar but not exactly the same.

Thank you! I hope this code helps anyone else in the future.

Edit: PS...i know it's weird, but I don't make games in AGK. Right now I'm making an app for people to meditate together in. It's coming along really well. This scrolling issue was just an annoyance the kept bothering me.

Login to post a reply

Server time is: 2024-09-30 19:20:44
Your offset time is: 2024-09-30 19:20:44