You can use this function to check and see if the calling instance would collide with any other instance in your game. Now, it should be noted that for this to work, the instance running the code must have a valid collision mask (either for the sprite itself, or through the mask_index) and it will only register collisions with those instances that also have a valid mask.

The function itself basically works by taking the instance and testing for collisions when placed at the position specified by the x/y arguments. The collision checking can be either precise or based on the bounding box of the instance, depending on what kind of collision mask has been selected.

Note that the given x/y coordinates will be floored to the nearest integer before the check is performed.


place_empty(x, y);

参数 描述
x The x position to check.
y The y position to check.




if place_empty(mouse_x, mouse_y)
   x = mouse_x;
   y = mouse_y;

The above code will check for a collision with any other instance if the calling instance were to be placed at the same position as the mouse. If there is no collision detected, then the instance has its x/y coordinates set to those of the mouse.