## **网格**
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]
~~~
- 简言
- 额外接口
- asset_get_index
- asset_get_type
- 粒子(PARTICLE)
- 简单粒子系统
- effect_create_below
- effect_create_above
- effect_clear
- ef_all
- 粒子系统
- 粒子系统的创建
- part_system_exists
- part_system_create
- part_system_create_layer
- part_system_get_layer
- part_system_layer
- part_system_clear
- part_system_depth
- part_system_position
- part_system_destroy
- part_particles_clear
- part_particles_count
- 系统绘图
- part_system_automatic_update
- part_system_automatic_draw
- part_system_update
- part_system_drawit
- part_system_draw_order
- 直接创建粒子
- part_particles_create
- part_particles_create_colour
- 粒子类型
- part_type_exists
- part_type_create
- part_type_destroy
- part_type_clear
- part_type_shape
- part_type_sprite
- part_type_size
- part_type_scale
- part_type_speed
- part_type_direction
- part_type_gravity
- part_type_orientation
- part_type_colour_mix
- part_type_colour_rgb
- part_type_colour_hsv
- part_type_colour1
- part_type_colour2
- part_type_colour3
- part_type_alpha1
- part_type_alpha2
- part_type_alpha3
- part_type_blend
- part_type_life
- part_type_step
- part_type_death
- 粒子发射器
- part_emitter_exists
- part_emitter_create
- part_emitter_clear
- part_emitter_region
- part_emitter_burst
- part_emitter_stream
- part_emitter_destroy
- part_emitter_destroy_all
- 数组(array)
- 数据结构(Data structures)
- 心得分享
- ds_exists
- ds_set_precision
- 网格(grid)
- ds_grid_create
- ds_grid_destroy
- ds_grid_width
- ds_grid_height
- ds_grid_resize
- ds_grid_clear
- ds_grid_set
- ds_grid_set_disk
- ds_grid_set_grid_region
- ds_grid_set_region
- ds_grid_shuffle
- ds_grid_sort
- ds_grid_get
- ds_grid_get_max
- ds_grid_get_mean
- ds_grid_get_min
- ds_grid_get_sum
- ds_grid_get_disk_max
- ds_grid_get_disk_mean
- ds_grid_get_disk_min
- ds_grid_get_disk_sum
- ds_grid_add
- ds_grid_add_region
- ds_grid_add_disk
- ds_grid_add_grid_region
- ds_grid_multiply
- ds_grid_multiply_disk
- ds_grid_multiply_region
- ds_grid_multiply_grid_region
- ds_grid_value_exists
- ds_grid_value_disk_exists
- ds_grid_value_x
- ds_grid_value_y
- ds_grid_value_disk_x
- ds_grid_value_disk_y
- ds_grid_copy
- ds_grid_read
- ds_grid_write
- 列表(list)
- 映射(map)
- 队列(Queues)
- 优先队列(Priority Queues)
- 堆栈(stack)