Documentation
¶
Overview ¶
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.GetTilesCount will always return 1. Use GetSceneTilesCount 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:
package main import ( "graphics.gd/classdb/TileMapLayer" "graphics.gd/classdb/TileSetScenesCollectionSource" "graphics.gd/variant/Object" "graphics.gd/variant/Vector2i" ) func ExampleTileSetScenesCollectionSource(tileMapLayer TileMapLayer.Instance, x, y int) { sourceId := tileMapLayer.GetCellSourceId(Vector2i.New(x, y)) if sourceId > -1 { var scene_source = tileMapLayer.TileSet().GetSource(sourceId) if scene_source, ok := Object.As[TileSetScenesCollectionSource.Instance](scene_source); ok { altId := tileMapLayer.GetCellAlternativeTile(Vector2i.New(x, y)) var scene = scene_source.GetSceneTileScene(altId) _ = scene } } }
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
- func (self *Extension[T]) AsResource() Resource.Instance
- func (self *Extension[T]) AsTileSetScenesCollectionSource() Instance
- func (self *Extension[T]) AsTileSetSource() TileSetSource.Instance
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) AsTileSetScenesCollectionSource() Instance
- func (self Instance) AsTileSetSource() TileSetSource.Instance
- func (self Instance) CreateSceneTile(packed_scene PackedScene.Instance) int
- func (self Instance) GetNextSceneTileId() int
- func (self Instance) GetSceneTileDisplayPlaceholder(id int) bool
- func (self Instance) GetSceneTileId(index int) int
- func (self Instance) GetSceneTileScene(id int) PackedScene.Instance
- func (self Instance) GetSceneTilesCount() int
- func (self Instance) HasSceneTileId(id int) bool
- func (self Instance) ID() ID
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) RemoveSceneTile(id int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSceneTileDisplayPlaceholder(id int, display_placeholder bool)
- func (self Instance) SetSceneTileId(id int, new_id int)
- func (self Instance) SetSceneTileScene(id int, packed_scene PackedScene.Instance)
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
func (*Extension[T]) AsTileSetScenesCollectionSource ¶
func (*Extension[T]) AsTileSetSource ¶
func (self *Extension[T]) AsTileSetSource() TileSetSource.Instance
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.TileSetScenesCollectionSource
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) AsTileSetScenesCollectionSource ¶
func (Instance) AsTileSetSource ¶
func (self Instance) AsTileSetSource() TileSetSource.Instance
func (Instance) CreateSceneTile ¶
func (self Instance) CreateSceneTile(packed_scene PackedScene.Instance) int
Creates a scene-based tile out of the given scene.
Returns a newly generated unique ID.
func (Instance) GetNextSceneTileId ¶
Returns the scene ID a following call to CreateSceneTile would return.
func (Instance) GetSceneTileDisplayPlaceholder ¶
Returns whether the scene tile with 'id' displays a placeholder in the editor.
func (Instance) GetSceneTileId ¶
Returns the scene tile ID of the scene tile at 'index'.
func (Instance) GetSceneTileScene ¶
func (self Instance) GetSceneTileScene(id int) PackedScene.Instance
Returns the PackedScene resource of scene tile with 'id'.
func (Instance) GetSceneTilesCount ¶
Returns the number or scene tiles this TileSet source has.
func (Instance) HasSceneTileId ¶
Returns whether this TileSet source has a scene tile with 'id'.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) RemoveSceneTile ¶
Remove the scene tile with 'id'.
func (Instance) SetSceneTileDisplayPlaceholder ¶
Sets whether or not the scene tile with 'id' should display a placeholder in the editor. This might be useful for scenes that are not visible.
func (Instance) SetSceneTileId ¶
Changes a scene tile's ID from 'id' to 'new_id'. This will fail if there is already a tile with an ID equal to 'new_id'.
func (Instance) SetSceneTileScene ¶
func (self Instance) SetSceneTileScene(id int, packed_scene PackedScene.Instance)
Assigns a PackedScene resource to the scene tile with 'id'. This will fail if the scene does not extend CanvasItem, as positioning properties are needed to place the scene on the TileMapLayer.
type MoreArgs ¶
type MoreArgs [1]gdclass.TileSetScenesCollectionSource
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) CreateSceneTile ¶
func (self MoreArgs) CreateSceneTile(packed_scene PackedScene.Instance, id_override int) int
Creates a scene-based tile out of the given scene.
Returns a newly generated unique ID.