多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## **网格** ds_grid基本上是一种二维数组。通过设置其整数宽度和高度来定义,以此来设置网格中“单元格”的总数(宽度和高度相乘),然后使用这些单元格来保存不同的数据(实数或字符串)。 这种类型的结构允许您通过给出它的x和y索引来设置和检索网格中的单元格值(从x和y轴开始为0,最大数值为宽度减1和高度减1)。同时,您还可以对特定的网格区域设置一个值值或者加上一个值,并在还可以对给定区域检索总和、最大值、最小值和平均值,这些特性使得该数据结构成为所有可用的数据结构中最为通用的。 当访问网格数据结构时,您应该始终尝试对单元格位置使用整数,否则所有非整数索引都会被GameMaker Studio 2覆盖。如果这不是您的需求,那么在传递您希望检查的索引之前,您需要先对自己进行舍入。 **注意:** 与所有动态资源一样,数据结构占用内存,因此在不再需要的情况下防止内存泄漏这些数据结构应该被销毁,因为内存泄漏将会减慢并最终导致您的游戏崩溃。 * * * * * 下面是处理网格的函数: * [ds_grid_create](ds_grid_create.md) * [ds_grid_destroy](ds_grid_destroy.md) * [ds_grid_width](ds_grid_width.md) * [ds_grid_height](ds_grid_height.md) * [ds_grid_resize](ds_grid_resize.md) * [ds_grid_clear](ds_grid_clear.md) * [ds_grid_set](ds_grid_set.md) * [ds_grid_set_disk](ds_grid_set_disk.md) * [ds_grid_set_grid_region](ds_grid_set_grid_region.md) * [ds_grid_set_region](ds_grid_set_region.md) * [ds_grid_shuffle](ds_grid_shuffle.md) * [ds_grid_sort](ds_grid_sort.md) * [ds_grid_get](ds_grid_get.md) * [ds_grid_get_max](ds_grid_get_max.md) * [ds_grid_get_mean](ds_grid_get_mean.md) * [ds_grid_get_min](ds_grid_get_min.md) * [ds_grid_get_sum](ds_grid_get_sum.md) * [ds_grid_get_disk_max](ds_grid_get_disk_max.md) * [ds_grid_get_disk_mean](ds_grid_get_disk_mean.md) * [ds_grid_get_disk_min](ds_grid_get_disk_min.md) * [ds_grid_get_disk_sum](ds_grid_get_disk_sum.md) * [ds_grid_add](ds_grid_add.md) * [ds_grid_add_region](ds_grid_add_region.md) * [ds_grid_add_disk](ds_grid_add_disk.md) * [ds_grid_add_grid_region](ds_grid_add_grid_region.md) * [ds_grid_multiply](ds_grid_multiply.md) * [ds_grid_multiply_disk](ds_grid_multiply_disk.md) * [ds_grid_multiply_region](ds_grid_multiply_region.md) * [ds_grid_multiply_grid_region](ds_grid_multiply_grid_region.md) * [ds_grid_value_exists](ds_grid_value_exists.md) * [ds_grid_value_disk_exists](ds_grid_value_disk_exists.md) * [ds_grid_value_x](ds_grid_value_x.md) * [ds_grid_value_y](ds_grid_value_y.md) * [ds_grid_value_disk_x](ds_grid_value_disk_x.md) * [ds_grid_value_disk_y](ds_grid_value_disk_y.md) * [ds_grid_copy](ds_grid_copy.md) * [ds_grid_read](ds_grid_read.md) * [ds_grid_write](ds_grid_write.md) 除了这些特定的函数,你可以使用一个表达式(称为访问器)来添加或修改你的ds_grid的内容。此访问器语法看起来类似于二维数组: ~~~ grid_index[# xpos, ypos] ~~~