MeBoingus
Member
Howdy all,
Often times I'll draw a sprite to the screen, and need to detect whether or not the mouse is 'inside' of it.
I normally use 'point_in_rectangle' for this, but the obviously this won't work for sprites with a precise collision mask.
Take this sprite, for example:
My goal is to run some code if the mouse is inside of the sprite, using a precise mask.
The only script/method I can think of that achieves this is:
However, (obviously) creating and destroying an instance constantly (this code runs in the draw event, as we are drawing the sprite to the screen) is HORRIBLY inefficient.
Does anyone know of a better way to handle this?
Warm regards .
Often times I'll draw a sprite to the screen, and need to detect whether or not the mouse is 'inside' of it.
I normally use 'point_in_rectangle' for this, but the obviously this won't work for sprites with a precise collision mask.
Take this sprite, for example:
My goal is to run some code if the mouse is inside of the sprite, using a precise mask.
The only script/method I can think of that achieves this is:
Code:
///mouse_in_sprite(sprite, x, y);
var tempO = instance_create(argument1, argument2, obj_mousein);
tempO.sprite_index = argument0;
if (position_meeting(mouse_x, mouse_y, tempO))
{
with (tempO) { instance_destroy(); }
return true;
}
with (tempO) { instance_destroy(); }
return false;
However, (obviously) creating and destroying an instance constantly (this code runs in the draw event, as we are drawing the sprite to the screen) is HORRIBLY inefficient.
Does anyone know of a better way to handle this?
Warm regards .