I usually use the nested if's with ands, like...
if GetPointerState() = 1
if GetPointerX() > 300 and GetPointerX() < 500
if GetPointerY() > 100 and GetPointerY() < 200
Print("You clicked my spot!")
endif
endif
endif
I used GetPointerState() in that example so the Text Printed would stay on the screen long enough to read it while you hold it down but a GetPointerPressed() would work for regular touch detection.
Below is a Swipe example that I am using in my current project... (it uses variables and a timer to tell if they are holding down on the screen and not accidentally tapping it)
// check for screen swipes
if GetPointerPressed() = 1
swipe_x = GetPointerX()
swipe_y = GetPointerY()
endif
if GetPointerState() = 1
if Timer() - pressed_time# > .5
if GetPointerY() > swipe_y + 40
if GetCameraAngleX(1) < 18
RotateCameraLocalX(1,.1)
endif
elseif GetPointerY() < swipe_y - 40
if GetCameraAngleX(1) > 5
RotateCameraLocalX(1,-.1)
endif
endif
if GetPointerX() > swipe_x + 40
RotateCameraGlobalY(1, .4)
elseif GetPointerX() < swipe_x - 40
RotateCameraGlobalY(1,-.4)
endif
endif
else
pressed_time# = Timer()
endif
That example is used to tilt/pan the camera in a 3d environment when you swipe the screen.
You can see that the original spot touched is the 0,0 point for the movement of the camera, regardless of where they move the finger while pressing down.
Just return the finger back to the starting point (or lift our finger up) to stop the camera movement. (note the 40 pixel buffer to make that spot bigger)
There is probably a better way to do it, but it works nicely for what I am doing. (i am also limiting the angle for panning too --> 18 or 5 in case anyone is wondering about that)
I hope this helps.
Quote: "i remember in past it was an invisible advertising block that eat the pointer state."
The only time I had a problem detecting the pointer was an invisible virtual button being in the way.
If you are hiding virtual buttons, then make sure it is not at that spot.
Maybe move its position off screen until you need it visible again, then move it back.
You could do that for any/all buttons when making them visible/invisible.
There is no GetVirtualButtonX() or Y command so you will need to hard code the locations, but...
SetVirtualButtonVisible( b, 0)
SetVirtualButtonPosition( b, -100, -100 )
// then later...
SetVirtualButtonPosition( b, 250, 400 )
SetVirtualButtonVisible( b, 1)
// where the 250 and 400 was the X and Y location of the button to start with when AddVirtualButton( index, x, y, size ) created it
Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1