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
Hereda: TileSetSource < Resource < RefCounted < Object
Expone un conjunto de escenas como tiles para un recurso TileSet.
Descripción
When placed on a TileMapLayer, tiles from TileSetScenesCollectionSource will automatically instantiate an associated scene at the cell's position in the TileMapLayer.
Scenes are instantiated as children of the TileMapLayer after it enters the tree, at the end of the frame (their creation is deferred). If you add/remove a scene tile in the TileMapLayer that is already inside the tree, the TileMapLayer will automatically instantiate/free the scene accordingly.
Note: Scene tiles all occupy one tile slot and instead use alternate tile ID to identify scene index. TileSetSource.get_tiles_count() will always return 1. Use get_scene_tiles_count() to get a number of scenes in a TileSetScenesCollectionSource.
Use this code if you want to find the scene path at a given tile in 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);
}
}
Métodos
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) |
Descripciones de Métodos
int create_scene_tile(packed_scene: PackedScene, id_override: int = -1) 🔗
Crea un tile basado en una escena a partir de la escena dada.
Devuelve un ID único recién generado.
int get_next_scene_tile_id() const 🔗
Devuelve el ID de escena que una llamada posterior a create_scene_tile() devolvería.
bool get_scene_tile_display_placeholder(id: int) const 🔗
Devuelve si el tile de escena con id muestra un marcador de posición en el editor.
int get_scene_tile_id(index: int) 🔗
Devuelve el ID del tile de escena en index.
PackedScene get_scene_tile_scene(id: int) const 🔗
Devuelve el recurso PackedScene del tile de escena con id.
Devuelve el número de tiles de escena que tiene este origen TileSet.
bool has_scene_tile_id(id: int) 🔗
Devuelve si este origen TileSet tiene un tile de escena con id.
void remove_scene_tile(id: int) 🔗
Eliminar el mosaico de escena con id.
void set_scene_tile_display_placeholder(id: int, display_placeholder: bool) 🔗
Establece si el tile de escena con id debe mostrar o no un marcador de posición en el editor. Esto podría ser útil para escenas que no son visibles.
void set_scene_tile_id(id: int, new_id: int) 🔗
Cambia el ID de un tile de escena de id a new_id. Esto fallará si ya hay un tile con un ID igual a new_id.
void set_scene_tile_scene(id: int, packed_scene: PackedScene) 🔗
Asigna un recurso PackedScene al tile de escena con id. Esto fallará si la escena no extiende CanvasItem, ya que se necesitan propiedades de posicionamiento para colocar la escena en TileMapLayer.