Get touch n as x,y

Post Reply
Ken
Posts: 29
Joined: Tue Jan 29, 2019 1:49 am
My devices: Ipad
Location: NSW, Australia

Get touch n as x,y

Post 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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Get touch n as x,y

Post by Mr. Kibernetik »

Yes, GET TOUCH works in main graphics view coordinates.

Ken
Posts: 29
Joined: Tue Jan 29, 2019 1:49 am
My devices: Ipad
Location: NSW, Australia

Re: Get touch n as x,y

Post by Ken »

Cheers, thanks

Ken
Posts: 29
Joined: Tue Jan 29, 2019 1:49 am
My devices: Ipad
Location: NSW, Australia

Coordinates within the sprite

Post 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.

Post Reply