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 / Need help to smoothly scroll camera by dragging on mobile

Author
Message
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 31st May 2017 03:57
OK, so i want to be able to drag the mobile UI up and down with a finger.

The game is heavy on tapping, it's pretty much ALL UI.

Problem is, if you tap your fingers quickly in multiple places, the screen jerks up and down rapidly.
Run my sample code, and broadcast to a mobile device, and tap 2 fingers back and forth, to see what i mean.

So what i need is a way to ignore those kind of taps, but still allowing dragging.

HALP?!




Thanks,

Bob
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 31st May 2017 21:34
i don't see off the top of my head how to apply that to my situation, but thanks.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 1st Jun 2017 09:12
Quote: "i don't see off the top of my head how to apply that to my situation, but thanks."

Require two fingers to drag instead of the one.
I use this technique in one of my unfinished projects. a single finger will rotate the camera, two fingers will move the camera.
Signature removed by mod because it's larger than 600x120... please resize and try again.
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 1st Jun 2017 21:36
I think in this case you don't necessarily need to use multiple touch events, you just need to use the GetRawTouch... commands to detect whether the player has tapped or swiped.

This simple example shows how to do the swipe to move a sprite:



To actually select something off the menu, you'll need to check if the RawTouchType is a 1 (ie screen is pressed then release within 1 second) and then use the GetRawTouchStartX() and GetRawTouchStartY() values to detect collision with the sprite.
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 2nd Jun 2017 15:20
OK, so,

thanks all.

Using a combination of the ideas posted here, i was able to make the system differentiate between multiple rapid taps and a screen drag.

it comes down to detecting all touch events during the loop, processing them individually.
Then, when the system thinks it's found a "drag" event, we check that event's length
IF GetRawTouchTime(index)>0.2
and if it's appropriately long, execute the drag.

i can now tap on 4 different points with basically no problem, and drag the screen around when necessary.

regarding "two fingers to drag",
i agree that does work,
but i find that when i try to make users do something in a new way, they tend to rebel against it.
people expect to be able to move the screen with a single finger.
But given a novel-enough game, i think most would be ok with it.

Login to post a reply

Server time is: 2024-04-27 02:42:04
Your offset time is: 2024-04-27 02:42:04