Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
TileSetSource¶
继承: Resource < RefCounted < Object
派生: TileSetAtlasSource, TileSetScenesCollectionSource
向 TileSet 资源暴露一组图块。
描述¶
向 TileSet 资源暴露一组图块。
源中的图块具有索引,索引为两个 ID,分别是坐标 ID(类型为 Vector2i)和备选 ID(类型为 int),名称反映了在 TileSetAtlasSource 中的使用方法。
根据 TileSet 源类型的不同,对这些 ID 的值可能有不同的限制,这就是 TileSetSource 基类仅暴露了 getter 的原因。
要遍历 TileSetSource 中暴露的所有图块,你可以首先使用 get_tiles_count 和 get_tile_id 遍历坐标 ID,然后使用 get_alternative_tiles_count 和 get_alternative_tile_id 遍历备选 ID。
警告:同一个 TileSetSource 不能同时属于两个 TileSet。对第二个 TileSet 调用 TileSet.add_source 会在第一个 TileSet 中移除该源。
方法¶
get_alternative_tile_id ( Vector2i atlas_coords, int index ) const |
|
get_alternative_tiles_count ( Vector2i atlas_coords ) const |
|
get_tile_id ( int index ) const |
|
get_tiles_count ( ) const |
|
has_alternative_tile ( Vector2i atlas_coords, int alternative_tile ) const |
|
方法说明¶
int get_alternative_tile_id ( Vector2i atlas_coords, int index ) const
返回坐标 ID 为 atlas_coords
的图块的索引为 index
的备选 ID。
int get_alternative_tiles_count ( Vector2i atlas_coords ) const
返回坐标 ID 为 atlas_coords
的图块的备选图块数量。
TileSetAtlasSource 返回的数量至少为 1,因为备选列表中始终存在 ID 为 0 的基础图块。
如果给定的坐标处没有图块,则返回 -1。
Vector2i get_tile_id ( int index ) const
返回索引为 index
的图块的图块坐标 ID。
int get_tiles_count ( ) const
返回该图集源中定义的图块数量(不含备选图块)。
bool has_alternative_tile ( Vector2i atlas_coords, int alternative_tile ) const
返回位于坐标 atlas_coords
的基础图块是否存在 ID 为 alternative_tile
的备选图块。
bool has_tile ( Vector2i atlas_coords ) const
返回该图集中是否存在坐标 ID 为 atlas_coords
的图块。