Hi! so, seemingly, the collision shape/area is set in "edit sprite" window, or with a collision_rectangle() function.
But what if my sprite is drawn on the GUI layer resized? (it is resized to the (drawn with scribble) string's width and height).
Tap Event works only on the initial 32x32 pixels of the sprite. How do i make it work on the whole sprite? I have tried setting collision rectangle manually in the step event collision_rectangle(x, y, text_w/sprite_width, text_h/sprite_height, self, false, false);, entering the same coordinates that i used in drawing the resized sprite draw_sprite_ext(sprite_index, image_index, x, y, text_w/sprite_width, text_h/sprite_height, 0, c_white, 1);
(text_w = scribble(text).get_width(); text_h = scribble(text).get_height();), but seems like it does not work that way.
#Collision area of a Tap Event
25 messages · Page 1 of 1 (latest)
you will have to use the step event instead of the tap event and you will need to use a point in rectangle call using the device mouse to gui position
let me try
i dont think it worked, or i am just ultra-stupid
interact();
}```
now since i deactivated tap event, it never runs interact()
are the x and y coordinates here local to the gui
do they have to be room coordinates or gui coordinates here? i have a function to convert room-to-gui coordinates, should i use it?
they definitely need to be in gui space for this to work
and the point in rectangle function takes corners not sizes
so you need x1 y1 and x2 y2. something like:
var mx = device_mouse_x_to_gui(0);
var my = device_mouse_y_to_gui(0);
var width = width_in_pixels_not_a_scale;
var height = height_in_pixels_not_a_scale;
var x1 = gui_space_x_position;
var y1 = gui_space_y_position;
var x2 = x1 + width;
var y2 = y1 + height;
if (point_in_rectangle(mx, my, x1, y1, x2, y2)) {
}```
does sprite_width (for example) give size in pixels, or a scale?
pixels
adjusted for scale
and you can do this in a step event, for mouseover/clicking stuff
so i did it like that now
interact();
}```
wtg stands for "world(room) to gui"
oh wait i am stupid
interact();
}```
nah it still doesnt work, or should i not be lazy and rewrite it in a clearer way using variables like in your example
oh, i used scale instead of width and height
okay, now it works but only for that sprite 32x32 area, ignoring the resize done in draw GUI event
wait
no, i dont know how do i get the size of the resized sprite in pixels
OH I KNOW