Page 1 of 1

Get touch n as x,y

Posted: Sun Jun 21, 2020 12:53 pm
by Ken
Does GET TOUCH N AS X,Y only work with screen coordinates?
I was trying to get it to work with a sprites coordinates, in a SPRITE BEGIN, SPRITE END.


GRAPHICS

GRAPHICS CLEAR 1,1,1
N$="mysprite"
SPRITE N$ BEGIN 200,100
GRAPHICS CLEAR 0,1,0
SPRITE END

SPRITE "mysprite" AT 800,400
SPRITE "mysprite" SHOW

SPRITE "mysprite" BEGIN
LOOP:
GET TOUCH 0 AS x,y
IF y > 0 AND y < 50 THEN
GRAPHICS CLEAR 1,0,0
END IF
GO TO LOOP

SPRITE END

Re: Get touch n as x,y

Posted: Sun Jun 21, 2020 4:41 pm
by Mr. Kibernetik
Yes, GET TOUCH works in main graphics view coordinates.

Re: Get touch n as x,y

Posted: Sun Jun 21, 2020 10:27 pm
by Ken
Cheers, thanks

Coordinates within the sprite

Posted: Sun Jun 21, 2020 11:17 pm
by Ken
Hi again

SPRITE_HIT (N$, X,Y) detects if the touch from GET TOUCH N AS X,Y is on the sprite.
There seems to no GET command for the coordinates on the sprite so I guess I can use subtraction with GET SPRITE N$ POS X,Y. Or I could put a small identical coloured sprite beside the other one.