You are not logged in.
Pages: 1
Hi,
I made a script that checks if a sprite at a given position meets a point.
You can use it when you want to draw a sprite and check if the user clicks on it.
///point_on_sprite(px,py, spr, x,y)
//
// Returns if the point (px,py) meets
// the sprite spr at the point (x,y)
//
// Code by Husi
/// GMLscripts.com/license
{
var tmp_mask, tmp_x,tmp_y, collision;
tmp_mask = mask_index;
tmp_x = x;
tmp_y = y;
mask_index = argument2;
x = argument3;
y = argument4;
collision = false;
if (position_meeting(argument0,argument1, id)) {
collision = true;
}
mask_index = tmp_mask;
x = tmp_x;
y = tmp_y;
return collision;
}
Example:
draw_sprite(sprite, subimage, x,y);
if (mouse_check_button_pressed(mb_left)) {
if (point_on_sprite(mouse_x,mouse_y, sprite, x,y))
show_message("you clicked at the sprite");
}
Hey,
I'm new here and didn't find a thread where I can say hello and wanted to open something like that.
About me:
I program since I am 11, now I'm 15 and living in Germany. The most time I spend on my computer and create scripts,programs,... . Unfortunately I made only one game (Flappy Bird Clone) because of my motivation.
If you want, that I help you, only send me a message here or else where
Also I can make some scripts when someone needs one. Only leave me a message!
Contact:
Discord - Husi012#0203
Twitter - @Husi012
E-Mail - gerrit.weiermann@gmx.de
Pages: 1