mp_grid_clear_cell

语法:

mp_grid_clear_cell(id, h, v);


参数 描述
id Index of the mp_grid that is to be used
h Horizontal position of the cell to clear
v vertical position of the cell to clear


返回: Boolean(布尔值)


描述

This function can be used to clear a specific "cell" of an mp_grid. Cells are not calculated as room coordinates, but rather as grid coordinates, where (0,0) is the top let corner of the grid. this means that to clear a cell at a specific position in the room, we must change the x and y coordinates into cell coordinate dividing them by the resolution of the mp_grid. The code example below shows how this works.


例如:

with (obj_Box)
   {
   mp_grid_clear_cell(grid, floor(x / 32), floor(y /32));
   instance_destroy();
   }

The above code will make all "obj_Box" destroy themselves and have them mark the cells they occupied in the mp_grid indexed in the variable "grid" as free. In this example, we find the appropriate cell by taking the x/y coordinate of the object and dividing them by the resolution of the grid (using floor to keep the values as integers);