Documentation
¶
Overview ¶
An atlas is a grid of tiles laid out on a texture. Each tile in the grid must be exposed using Instance.CreateTile. Those tiles are then indexed using their coordinates in the grid.
Each tile can also have a size in the grid coordinates, making it more or less cells in the atlas.
Alternatives version of a tile can be created using Instance.CreateAlternativeTile, which are then indexed using an alternative ID. The main tile (the one in the grid), is accessed with an alternative ID equal to 0.
Each tile alternate has a set of properties that is defined by the source's graphics.gd/classdb/TileSet layers. Those properties are stored in a TileData object that can be accessed and modified using Instance.GetTileData.
As TileData properties are stored directly in the TileSetAtlasSource resource, their properties might also be set using TileSetAtlasSource.set("<coords_x>:<coords_y>/<alternative_id>/<tile_data_property>").
Index ¶
- Constants
- type Advanced
- type Any
- type Expanded
- func (self Expanded) CreateAlternativeTile(atlas_coords Vector2i.XY, alternative_id_override int) int
- func (self Expanded) CreateTile(atlas_coords Vector2i.XY, size Vector2i.XY)
- func (self Expanded) GetTileTextureRegion(atlas_coords Vector2i.XY, frame_ int) Rect2i.PositionSize
- func (self Expanded) HasRoomForTile(atlas_coords Vector2i.XY, size Vector2i.XY, animation_columns int, ...) bool
- func (self Expanded) MoveTileInAtlas(atlas_coords Vector2i.XY, new_atlas_coords Vector2i.XY, new_size Vector2i.XY)
- type Extension
- 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) AsTileSetAtlasSource() Instance
- func (self Instance) AsTileSetSource() TileSetSource.Instance
- func (self Instance) ClearTilesOutsideTexture()
- func (self Instance) CreateAlternativeTile(atlas_coords Vector2i.XY) int
- func (self Instance) CreateTile(atlas_coords Vector2i.XY)
- func (self Instance) GetAtlasGridSize() Vector2i.XY
- func (self Instance) GetNextAlternativeTileId(atlas_coords Vector2i.XY) int
- func (self Instance) GetRuntimeTexture() Texture2D.Instance
- func (self Instance) GetRuntimeTileTextureRegion(atlas_coords Vector2i.XY, frame_ int) Rect2i.PositionSize
- func (self Instance) GetTileAnimationColumns(atlas_coords Vector2i.XY) int
- func (self Instance) GetTileAnimationFrameDuration(atlas_coords Vector2i.XY, frame_index int) Float.X
- func (self Instance) GetTileAnimationFramesCount(atlas_coords Vector2i.XY) int
- func (self Instance) GetTileAnimationMode(atlas_coords Vector2i.XY) TileAnimationMode
- func (self Instance) GetTileAnimationSeparation(atlas_coords Vector2i.XY) Vector2i.XY
- func (self Instance) GetTileAnimationSpeed(atlas_coords Vector2i.XY) Float.X
- func (self Instance) GetTileAnimationTotalDuration(atlas_coords Vector2i.XY) Float.X
- func (self Instance) GetTileAtCoords(atlas_coords Vector2i.XY) Vector2i.XY
- func (self Instance) GetTileData(atlas_coords Vector2i.XY, alternative_tile int) TileData.Instance
- func (self Instance) GetTileSizeInAtlas(atlas_coords Vector2i.XY) Vector2i.XY
- func (self Instance) GetTileTextureRegion(atlas_coords Vector2i.XY) Rect2i.PositionSize
- func (self Instance) GetTilesToBeRemovedOnChange(texture Texture2D.Instance, margins Vector2i.XY, separation Vector2i.XY, ...) []Vector2.XY
- func (self Instance) HasRoomForTile(atlas_coords Vector2i.XY, size Vector2i.XY, animation_columns int, ...) bool
- func (self Instance) HasTilesOutsideTexture() bool
- func (self Instance) ID() ID
- func (self Instance) Margins() Vector2i.XY
- func (self Instance) MoveTileInAtlas(atlas_coords Vector2i.XY)
- func (self Instance) RemoveAlternativeTile(atlas_coords Vector2i.XY, alternative_tile int)
- func (self Instance) RemoveTile(atlas_coords Vector2i.XY)
- func (self Instance) Separation() Vector2i.XY
- func (self Instance) SetAlternativeTileId(atlas_coords Vector2i.XY, alternative_tile int, new_id int)
- func (self Instance) SetMargins(value Vector2i.XY)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSeparation(value Vector2i.XY)
- func (self Instance) SetTexture(value Texture2D.Instance)
- func (self Instance) SetTextureRegionSize(value Vector2i.XY)
- func (self Instance) SetTileAnimationColumns(atlas_coords Vector2i.XY, frame_columns int)
- func (self Instance) SetTileAnimationFrameDuration(atlas_coords Vector2i.XY, frame_index int, duration Float.X)
- func (self Instance) SetTileAnimationFramesCount(atlas_coords Vector2i.XY, frames_count int)
- func (self Instance) SetTileAnimationMode(atlas_coords Vector2i.XY, mode TileAnimationMode)
- func (self Instance) SetTileAnimationSeparation(atlas_coords Vector2i.XY, separation Vector2i.XY)
- func (self Instance) SetTileAnimationSpeed(atlas_coords Vector2i.XY, speed Float.X)
- func (self Instance) SetUseTexturePadding(value bool)
- func (self Instance) Texture() Texture2D.Instance
- func (self Instance) TextureRegionSize() Vector2i.XY
- func (self Instance) UseTexturePadding() bool
- func (self Instance) Virtual(name string) reflect.Value
- type TileAnimationMode
Constants ¶
const TransformFlipH = 4096 //gd:TileSetAtlasSource.TRANSFORM_FLIP_H
const TransformFlipV = 8192 //gd:TileSetAtlasSource.TRANSFORM_FLIP_V
const TransformTranspose = 16384 //gd:TileSetAtlasSource.TRANSFORM_TRANSPOSE
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 Expanded ¶
type Expanded [1]gdclass.TileSetAtlasSource
func (Expanded) CreateAlternativeTile ¶
func (self Expanded) CreateAlternativeTile(atlas_coords Vector2i.XY, alternative_id_override int) int
Creates an alternative tile for the tile at coordinates 'atlas_coords'. If 'alternative_id_override' is -1, give it an automatically generated unique ID, or assigns it the given ID otherwise.
Returns the new alternative identifier, or -1 if the alternative could not be created with a provided 'alternative_id_override'.
func (Expanded) CreateTile ¶
Creates a new tile at coordinates 'atlas_coords' with the given 'size'.
func (Expanded) GetTileTextureRegion ¶
Returns a tile's texture region in the atlas texture. For animated tiles, a 'frame' argument might be provided for the different frames of the animation.
func (Expanded) HasRoomForTile ¶
func (self Expanded) HasRoomForTile(atlas_coords Vector2i.XY, size Vector2i.XY, animation_columns int, animation_separation Vector2i.XY, frames_count int, ignored_tile Vector2i.XY) bool
Returns whether there is enough room in an atlas to create/modify a tile with the given properties. If 'ignored_tile' is provided, act as is the given tile was not present in the atlas. This may be used when you want to modify a tile's properties.
func (Expanded) MoveTileInAtlas ¶
func (self Expanded) MoveTileInAtlas(atlas_coords Vector2i.XY, new_atlas_coords Vector2i.XY, new_size Vector2i.XY)
Move the tile and its alternatives at the 'atlas_coords' coordinates to the 'new_atlas_coords' coordinates with the 'new_size' size. This functions will fail if a tile is already present in the given area.
If 'new_atlas_coords' is Vector2i(-1, -1), keeps the tile's coordinates. If 'new_size' is Vector2i(-1, -1), keeps the tile's size.
To avoid an error, first check if a move is possible using Instance.HasRoomForTile.
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]) AsTileSetAtlasSource ¶
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.TileSetAtlasSource
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) AsTileSetAtlasSource ¶
func (Instance) AsTileSetSource ¶
func (self Instance) AsTileSetSource() TileSetSource.Instance
func (Instance) ClearTilesOutsideTexture ¶
func (self Instance) ClearTilesOutsideTexture()
Removes all tiles that don't fit the available texture area. This method iterates over all the source's tiles, so it's advised to use Instance.HasTilesOutsideTexture beforehand.
func (Instance) CreateAlternativeTile ¶
Creates an alternative tile for the tile at coordinates 'atlas_coords'. If 'alternative_id_override' is -1, give it an automatically generated unique ID, or assigns it the given ID otherwise.
Returns the new alternative identifier, or -1 if the alternative could not be created with a provided 'alternative_id_override'.
func (Instance) CreateTile ¶
Creates a new tile at coordinates 'atlas_coords' with the given 'size'.
func (Instance) GetAtlasGridSize ¶
Returns the atlas grid size, which depends on how many tiles can fit in the texture. It thus depends on the Instance.Texture's size, the atlas Instance.Margins, and the tiles' Instance.TextureRegionSize.
func (Instance) GetNextAlternativeTileId ¶
Returns the alternative ID a following call to Instance.CreateAlternativeTile would return.
func (Instance) GetRuntimeTexture ¶
If Instance.UseTexturePadding is false, returns Instance.Texture. Otherwise, returns and internal graphics.gd/classdb/ImageTexture created that includes the padding.
func (Instance) GetRuntimeTileTextureRegion ¶
func (self Instance) GetRuntimeTileTextureRegion(atlas_coords Vector2i.XY, frame_ int) Rect2i.PositionSize
Returns the region of the tile at coordinates 'atlas_coords' for the given 'frame' inside the texture returned by Instance.GetRuntimeTexture.
Note: If Instance.UseTexturePadding is false, returns the same as Instance.GetTileTextureRegion.
func (Instance) GetTileAnimationColumns ¶
Returns how many columns the tile at 'atlas_coords' has in its animation layout.
func (Instance) GetTileAnimationFrameDuration ¶
func (self Instance) GetTileAnimationFrameDuration(atlas_coords Vector2i.XY, frame_index int) Float.X
Returns the animation frame duration of frame 'frame_index' for the tile at coordinates 'atlas_coords'.
func (Instance) GetTileAnimationFramesCount ¶
Returns how many animation frames has the tile at coordinates 'atlas_coords'.
func (Instance) GetTileAnimationMode ¶
func (self Instance) GetTileAnimationMode(atlas_coords Vector2i.XY) TileAnimationMode
Returns the tile animation mode of the tile at 'atlas_coords'. See also Instance.SetTileAnimationMode.
func (Instance) GetTileAnimationSeparation ¶
Returns the separation (as in the atlas grid) between each frame of an animated tile at coordinates 'atlas_coords'.
func (Instance) GetTileAnimationSpeed ¶
Returns the animation speed of the tile at coordinates 'atlas_coords'.
func (Instance) GetTileAnimationTotalDuration ¶
Returns the sum of the sum of the frame durations of the tile at coordinates 'atlas_coords'. This value needs to be divided by the animation speed to get the actual animation loop duration.
func (Instance) GetTileAtCoords ¶
If there is a tile covering the 'atlas_coords' coordinates, returns the top-left coordinates of the tile (thus its coordinate ID). Returns Vector2i(-1, -1) otherwise.
func (Instance) GetTileData ¶
Returns the graphics.gd/classdb/TileData object for the given atlas coordinates and alternative ID.
func (Instance) GetTileSizeInAtlas ¶
Returns the size of the tile (in the grid coordinates system) at coordinates 'atlas_coords'.
func (Instance) GetTileTextureRegion ¶
func (self Instance) GetTileTextureRegion(atlas_coords Vector2i.XY) Rect2i.PositionSize
Returns a tile's texture region in the atlas texture. For animated tiles, a 'frame' argument might be provided for the different frames of the animation.
func (Instance) GetTilesToBeRemovedOnChange ¶
func (self Instance) GetTilesToBeRemovedOnChange(texture Texture2D.Instance, margins Vector2i.XY, separation Vector2i.XY, texture_region_size Vector2i.XY) []Vector2.XY
Returns an array of tiles coordinates ID that will be automatically removed when modifying one or several of those properties: 'texture', 'margins', 'separation' or 'texture_region_size'. This can be used to undo changes that would have caused tiles data loss.
func (Instance) HasRoomForTile ¶
func (self Instance) HasRoomForTile(atlas_coords Vector2i.XY, size Vector2i.XY, animation_columns int, animation_separation Vector2i.XY, frames_count int) bool
Returns whether there is enough room in an atlas to create/modify a tile with the given properties. If 'ignored_tile' is provided, act as is the given tile was not present in the atlas. This may be used when you want to modify a tile's properties.
func (Instance) HasTilesOutsideTexture ¶
Checks if the source has any tiles that don't fit the texture area (either partially or completely).
func (Instance) MoveTileInAtlas ¶
Move the tile and its alternatives at the 'atlas_coords' coordinates to the 'new_atlas_coords' coordinates with the 'new_size' size. This functions will fail if a tile is already present in the given area.
If 'new_atlas_coords' is Vector2i(-1, -1), keeps the tile's coordinates. If 'new_size' is Vector2i(-1, -1), keeps the tile's size.
To avoid an error, first check if a move is possible using Instance.HasRoomForTile.
func (Instance) RemoveAlternativeTile ¶
Remove a tile's alternative with alternative ID 'alternative_tile'.
Calling this function with 'alternative_tile' equals to 0 will fail, as the base tile alternative cannot be removed.
func (Instance) RemoveTile ¶
Remove a tile and its alternative at coordinates 'atlas_coords'.
func (Instance) Separation ¶
func (Instance) SetAlternativeTileId ¶
func (self Instance) SetAlternativeTileId(atlas_coords Vector2i.XY, alternative_tile int, new_id int)
Change a tile's alternative ID from 'alternative_tile' to 'new_id'.
Calling this function with 'new_id' of 0 will fail, as the base tile alternative cannot be moved.
func (Instance) SetMargins ¶
func (Instance) SetSeparation ¶
func (Instance) SetTexture ¶
func (Instance) SetTextureRegionSize ¶
func (Instance) SetTileAnimationColumns ¶
Sets the number of columns in the animation layout of the tile at coordinates 'atlas_coords'. If set to 0, then the different frames of the animation are laid out as a single horizontal line in the atlas.
func (Instance) SetTileAnimationFrameDuration ¶
func (self Instance) SetTileAnimationFrameDuration(atlas_coords Vector2i.XY, frame_index int, duration Float.X)
Sets the animation frame 'duration' of frame 'frame_index' for the tile at coordinates 'atlas_coords'.
func (Instance) SetTileAnimationFramesCount ¶
Sets how many animation frames the tile at coordinates 'atlas_coords' has.
func (Instance) SetTileAnimationMode ¶
func (self Instance) SetTileAnimationMode(atlas_coords Vector2i.XY, mode TileAnimationMode)
Sets the tile animation mode of the tile at 'atlas_coords' to 'mode'. See also Instance.GetTileAnimationMode.
func (Instance) SetTileAnimationSeparation ¶
Sets the margin (in grid tiles) between each tile in the animation layout of the tile at coordinates 'atlas_coords' has.
func (Instance) SetTileAnimationSpeed ¶
Sets the animation speed of the tile at coordinates 'atlas_coords' has.
func (Instance) SetUseTexturePadding ¶
func (Instance) TextureRegionSize ¶
func (Instance) UseTexturePadding ¶
type TileAnimationMode ¶
type TileAnimationMode int //gd:TileSetAtlasSource.TileAnimationMode
const ( // Tile animations start at same time, looking identical. TileAnimationModeDefault TileAnimationMode = 0 // Tile animations start at random times, looking varied. TileAnimationModeRandomStartTimes TileAnimationMode = 1 // Represents the size of the [TileAnimationMode] enum. TileAnimationModeMax TileAnimationMode = 2 )