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.

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 中移除該源。

方法

int

get_alternative_tile_id(atlas_coords: Vector2i, index: int) const

int

get_alternative_tiles_count(atlas_coords: Vector2i) const

Vector2i

get_tile_id(index: int) const

int

get_tiles_count() const

bool

has_alternative_tile(atlas_coords: Vector2i, alternative_tile: int) const

bool

has_tile(atlas_coords: Vector2i) const


方法說明

int get_alternative_tile_id(atlas_coords: Vector2i, index: int) const 🔗

返回座標 ID 為 atlas_coords 的圖塊的索引為 index 的備選 ID。


int get_alternative_tiles_count(atlas_coords: Vector2i) const 🔗

返回座標 ID 為 atlas_coords 的圖塊的備選圖塊數量。

TileSetAtlasSource 返回的數量至少為 1,因為備選列表中始終存在 ID 為 0 的基礎圖塊。

如果給定的座標處沒有圖塊,則返回 -1。


Vector2i get_tile_id(index: int) const 🔗

返回索引為 index 的圖塊的圖塊座標 ID。


int get_tiles_count() const 🔗

返回該合集源中定義的圖塊數量(不含備選圖塊)。


bool has_alternative_tile(atlas_coords: Vector2i, alternative_tile: int) const 🔗

返回位於座標 atlas_coords 的基礎圖塊是否存在 ID 為 alternative_tile 的備選圖塊。


bool has_tile(atlas_coords: Vector2i) const 🔗

返回該合集中是否存在座標 ID 為 atlas_coords 的圖塊。