通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
GameMaker Studio 2[场景编辑器](场景编辑器.md)允许您使用层在任何给定的场景中添加瓷片。顾名思义,tilemap层就是一组瓷片集合,它们在一个场景内被定义在同一深度,并且可以通过叠加层来控制不同元素的相互覆盖关系。您还可以利用代码在游戏运行过程中动态控制层的某些属性,进行添加或删除操作,甚至是修改图层所包含的元素。请注意,在房间编辑器中,每个层(Tile层)限制只能有一个瓷片集(tilemap),但是用代码控制则没有这种限制,您可以将多个瓷片集分配给一个单独的层,每个瓷片集都会具有自己惟一的ID和属性,因此: * tile set是用来创建tile layers和tilemaps的资源。 * tile layer是您在房间编辑器中创建的,用来添加tilesets的图层。 * tilemap是您所在房间编辑器或代码中添加到一个层内的tile的集合,一整个tilemap是层上的一个独立元素。 下面列出了可以用于编辑tilemap图层的所有功能: * layer_tilemap_get_id * layer_tilemap_exists * layer_tilemap_create * layer_tilemap_destroy * tilemap_tileset * tilemap_clear * tilemap_x * tilemap_y * tilemap_set * tilemap_set_at_pixel * tilemap_set_mask * tilemap_set_global_mask * tilemap_get_mask * tilemap_get_global_mask * tilemap_get_tileset * tilemap_get_frame * tilemap_get_tile_width * tilemap_get_tile_height * tilemap_get_width * tilemap_get_height * tilemap_get_x * tilemap_get_y * tilemap_get * tilemap_get_at_pixel * tilemap_get_cell_x_at_pixel * tilemap_get_cell_y_at_pixel * draw_tilemap ## 瓷片函数(Tile Functions) Apart from the functions listed above to set tilemaps, you also have a number of functions that can be used to manipulate the data of individual tiles. A "blob" of tile data is made up of the tile index plus a few extra bits to show whether the tile has been rotated, flipped or mirrored. You also have the possibility of adding your own bitmask to the tile data, although this is for advanced users only as you will be masking off bits that are reserved for the tile index - essentially there are 19 bits reserved for your tile indices, but if you only use 8 of them, then you have eleven bits left over that can be used to create a custom mask. This mask can then be used and checked in code to create custom tile collisions or whatever. However, you would normally not need to create your own tiledata blobs, and would instead use the function tilemap_get to get the tiledata, then you would manipulate it using the functions below, and then you would set it again using tilemap_set. 除了上述用于设置瓷片集(tilemap)的函数之外,你还可以使用函数来操作单个瓷片(tiles)。单个瓷片图像“blob”是由瓷片索引及一些额外属性构成的,这些额外属性会标识瓷片是否旋转、垂直翻转或水平镜像翻转等。你还可以添加自己的位掩码(bitmask)标识,当然这是给有进阶功能需求的用户使用的,你可以屏蔽掉瓷片索引所使用的掩码位——理论上一共有19位可以用于索引标识,如果你只用了其中的8位,那就还剩下11位可以用来自定义掩码。你可以用这个自定义掩码来检查瓷片碰撞等你需要的特定功能。但是通常来说你不用自己创建瓷片单元,而是直接用“tilemap_get”函数来获取瓷片数据(tiledata),然后用下述函数来进行相关操作,最后用“tilemap_set”来设置并使用它。 以下为用于编辑tiles的函数列表: * tile_get_empty * tile_get_index * tile_get_flip * tile_get_mirror * tile_get_rotate * tile_set_empty * tile_set_index * tile_set_flip * tile_set_mirror * tile_set_rotate * draw_tile * draw_tile_ext