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...
TileSetScenesCollectionSource
Успадковує: TileSetSource < Resource < RefCounted < Object
Експолює набір сцен, як плитка для ресурсу TileSet.
Опис
При розміщенні на TileMapLayer, плитки з TileSetScenesCollectionSource автоматично створять екземпляр пов'язаної сцени в позиції комірки в TileMapLayer.
Сцени створюються як дочірні елементи TileMapLayer після того, як він потрапляє в дерево, в кінці кадру (їхнє створення відкладається). Якщо ви додаєте/видаляєте плитку сцени в TileMapLayer, яка вже знаходиться всередині дерева, TileMapLayer автоматично створить/звільнить сцену відповідно.
Примітка: Плитки сцен займають один слот плитки та натомість використовують альтернативний ідентифікатор плитки для ідентифікації індексу сцени. TileSetSource.get_tiles_count() завжди повертатиме 1. Використовуйте get_scene_tiles_count(), щоб отримати кількість сцен у TileSetScenesCollectionSource.
Використовуйте цей код, якщо ви хочете знайти шлях сцени на заданій плитці в TileMapLayer:
var source_id = tile_map_layer.get_cell_source_id(Vector2i(x, y))
if source_id > -1:
var scene_source = tile_map_layer.tile_set.get_source(source_id)
if scene_source is TileSetScenesCollectionSource:
var alt_id = tile_map_layer.get_cell_alternative_tile(Vector2i(x, y))
# The assigned PackedScene.
var scene = scene_source.get_scene_tile_scene(alt_id)
int sourceId = tileMapLayer.GetCellSourceId(new Vector2I(x, y));
if (sourceId > -1)
{
TileSetSource source = tileMapLayer.TileSet.GetSource(sourceId);
if (source is TileSetScenesCollectionSource sceneSource)
{
int altId = tileMapLayer.GetCellAlternativeTile(new Vector2I(x, y));
// The assigned PackedScene.
PackedScene scene = sceneSource.GetSceneTileScene(altId);
}
}
Методи
create_scene_tile(packed_scene: PackedScene, id_override: int = -1) |
|
get_next_scene_tile_id() const |
|
get_scene_tile_display_placeholder(id: int) const |
|
get_scene_tile_id(index: int) |
|
get_scene_tile_scene(id: int) const |
|
has_scene_tile_id(id: int) |
|
void |
remove_scene_tile(id: int) |
void |
set_scene_tile_display_placeholder(id: int, display_placeholder: bool) |
void |
set_scene_tile_id(id: int, new_id: int) |
void |
set_scene_tile_scene(id: int, packed_scene: PackedScene) |
Описи методів
int create_scene_tile(packed_scene: PackedScene, id_override: int = -1) 🔗
Створює сценографічну плитку з даної сцени.
Повернутися до новоствореного ID.
int get_next_scene_tile_id() const 🔗
Повертаємо вашу увагу на те, що у вас є наступний виклик.
bool get_scene_tile_display_placeholder(id: int) const 🔗
Повертаємо вашу увагу на те, що кахельна плитка з id відображає власника місця в редакторі.
int get_scene_tile_id(index: int) 🔗
Повертає ідентифікатор плитки сцени за адресою index.
PackedScene get_scene_tile_scene(id: int) const 🔗
Повернення PackedScene ресурс сценової плитки з id.
Повертає кількість або сцена плитки це джерело TileSet.
bool has_scene_tile_id(id: int) 🔗
Повертає, чи є це джерело TileSet має сцену плитку id.
void remove_scene_tile(id: int) 🔗
Видаліть сцену плитку id.
void set_scene_tile_display_placeholder(id: int, display_placeholder: bool) 🔗
Налаштовує, чи не на сцені плитка з id повинна відображатися власник місця в редакторі. Це може бути корисним для сцени, які не видно.
void set_scene_tile_id(id: int, new_id: int) 🔗
Змінює ідентифікатор плитки сцени з id на new_id. Це не вдасться, якщо вже існує плитка з ідентифікатором, що дорівнює new_id.
void set_scene_tile_scene(id: int, packed_scene: PackedScene) 🔗
Призначає ресурс PackedScene плитці сцени з id. Це не вдасться, якщо сцена не розширює CanvasItem, оскільки для розміщення сцени на TileMapLay потрібні властивості позиціонування.