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 / Problem using GetRowTouch for jump function

Author
Message
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 21st Sep 2015 09:22
In my game I have 2 jump types, the first jump is the short jump and the second is the long jump, when the screen touched, the player jump, but now I need to make the player long jump. I know how to do it, but I do not know how to do it using the GetRowTouch or PointerState function.

If I use GetPointerPressed()=1 for the short jump, and GetPointerState()=1 for the long jump, won't work, because the PointerPressed and PointerState are called in the same time, I do not need the player to do the short and long jump at the same time, I need just 1 type of jump each time

I found an solution, but this solution have problem:
I can use GetRawTouchType for this (1= short, 2= long), it is great!
but the problem is the GetRawTouchType()=2 are called only 1 second later... I need to be called when the touch are hold, wait 1 second for do the long jump won't work for me... How I can change this time? Why the AppGameKit don't use miliseconds???
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Sep 2015 10:09
The Touch Types are a basic implementation of this kind of system. Some people can use it, some can't. TGC had to make a decision on what constitutes a long touch, and one second is a widely used threshold.

For your scenario, simply record the timer() on getPointerPressed(). Then use GetPointerState() and this saved time to detect when it has been held down for more than the time you choose. I have used 0.25 seconds in one of my apps, which works well for me. A "tap" is often considered < 0.1 seconds and is probably a better threshold for a fast game..

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 21st Sep 2015 23:27
Similar to Batvink's suggestion: if you used the GetRawTouchEvent() command you can then use the GetRawTouchTime() command to time the event. It's ever so slightly easier than using the pointer commands as you don't need to record the time when the screen was pressed.

Although, the pointer command is a more universal if you care about it working on a normal computer with a mouse or keyboard.

Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 22nd Sep 2015 07:12
Quote: "The Touch Types are a basic implementation of this kind of system. Some people can use it, some can't. TGC had to make a decision on what constitutes a long touch, and one second is a widely used threshold.

For your scenario, simply record the timer() on getPointerPressed(). Then use GetPointerState() and this saved time to detect when it has been held down for more than the time you choose. I have used 0.25 seconds in one of my apps, which works well for me. A "tap" is often considered < 0.1 seconds and is probably a better threshold for a fast game.."


How to use this timer?



It return a thousand number in seconds (ex: 2000, 2001, 2002, 2003)
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 22nd Sep 2015 16:12
Here is what I would do.



Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Sep 2015 16:13
Quote: "Why the AppGameKit don't use miliseconds???"

Quote: "How to use this timer?
It return a thousand number in seconds (ex: 2000, 2001, 2002, 2003)"


These things all make sense now. This:

time = Timer()

Should be:

time# = Timer()

Then you will get milliseconds.

Time is an integer
Time# is a float (decimals)

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 23rd Sep 2015 07:57 Edited at: 23rd Sep 2015 08:21
Quote: "These things all make sense now. This:

time = Timer()

Should be:

time# = Timer()

Then you will get milliseconds.

Time is an integer
Time# is a float (decimals)"


I used "as Float" to declare the variable, but I accidentaly wrong the name of variable when I call he LOL

Thanks Crazy Programmer, I take your logic and changed for it:



using it call the function timer() only when touch/click on the screen.

Thanks all!
When you come to Brazil, I pay a beer for you
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 23rd Sep 2015 16:19
Glad we could help

The reason I set the GameTime = Timer() at the top of the loop was because there is a huge chance you will need timers for a few other things in your game.

So you can always refer to GameTime when you need to do something based off a timer event...Instead of calling Timer() 10 times all over the place

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim

Login to post a reply

Server time is: 2024-09-29 05:28:57
Your offset time is: 2024-09-29 05:28:57