Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Game programming

getting touch coordinates in onTouchSequenceBegin

All about the StoneScript

getting touch coordinates in onTouchSequenceBegin

Postby oo7 » 21 Jul 2012, 21:40

how to gett the touch coordinates,namely nY0,nY0 in onTouchSequenceBegin and onTouchSequenceHandlers.there arent any parameters associated with these functions!
oo7
Fresh Boarder
Fresh Boarder
 
Posts: 7

Re: getting touch coordinates in onTouchSequenceBegin

Postby Fraser » 22 Jul 2012, 01:45

Hi oo7,

Open the sample projects folder
Open game called "iPhoneCharacterControl"
Open AI model "iPhoneJoypadEmulation"

In there you will see a good example of using the touch handlers.

onTouchSequenceBegin
onTouchSequenceChange
onTouchSequenceEnd

Tracking touch events is quite involved but this sample shows you everthing you need to know.
Fraser Ashworth,
https://www.cortex7.net
User avatar
Fraser
Platinum Boarder
Platinum Boarder
 
Posts: 1086
Location: Europe

Re: getting touch coordinates in onTouchSequenceBegin

Postby Selzier » 22 Jul 2012, 03:31

I would like to know how to get the touch coordinates in onTouchSequenceBegin AND in onTouchSequenceEnd.

In each individual "onTouchSequenceChange" set, I suppose you could set up variables to catch the first and last "TouchChange" but just getting these in the begin and end handlers makes more sense.

I tried manually calling a "nTaps0, nX0, nY0" but this didn't work!
Selzier
Platinum Boarder
Platinum Boarder
 
Posts: 517
Location: Boise

Re: getting touch coordinates in onTouchSequenceBegin

Postby RedQueen » 22 Jul 2012, 07:14

Have you tried having the onMouseDown and onMouseUp to push the information to a global variable and then have the onTouchSequenceBegin pull that information and go from there?? Because even though it is on mobile well from what I seen on android app I am programming the onMouseDown is still triggered even though there is no actual mouse. So that will give you the position that the person pressed down at.

I just pull the mouse hit position so that I can cast a ray to see what object that the player is hitting.
RedQueen
Platinum Boarder
Platinum Boarder
 
Posts: 328

Re: getting touch coordinates in onTouchSequenceBegin

Postby Fraser » 22 Jul 2012, 14:02

Selzier wrote:I would like to know how to get the touch coordinates in onTouchSequenceBegin AND in onTouchSequenceEnd.

In each individual "onTouchSequenceChange" set, I suppose you could set up variables to catch the first and last "TouchChange" but just getting these in the begin and end handlers makes more sense.

I tried manually calling a "nTaps0, nX0, nY0" but this didn't work!


I think you'll find a begin event is always followed by a change event, the begin event just tells you when the sequence begins. You can press the touchscreen as carefuly as you want and not drag, it generates begin followed by change.

Set a bool flag in begin and then check it in change, if true then handle it as that change as the first touch event, and clear the flag.

Store all touch coords in the change handler. Then in the end handler read those as the end coords.

Multitouch tracking is complex, you need to keep track of the events based on nTaps, I highly recommend using the iphonecontrol sample code as a foundation/reference.
Fraser Ashworth,
https://www.cortex7.net
User avatar
Fraser
Platinum Boarder
Platinum Boarder
 
Posts: 1086
Location: Europe


Return to Game programming