TileSetAtlasSource

package
v0.0.0-...-c858641 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 29 Imported by: 0

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

View Source
const TransformFlipH = 4096 //gd:TileSetAtlasSource.TRANSFORM_FLIP_H
View Source
const TransformFlipV = 8192 //gd:TileSetAtlasSource.TRANSFORM_FLIP_V
View Source
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 Any

type Any interface {
	gd.IsClass
	AsTileSetAtlasSource() Instance
}

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

func (self Expanded) CreateTile(atlas_coords Vector2i.XY, size Vector2i.XY)

Creates a new tile at coordinates 'atlas_coords' with the given 'size'.

func (Expanded) GetTileTextureRegion

func (self Expanded) GetTileTextureRegion(atlas_coords Vector2i.XY, frame_ int) 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 (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

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsTileSetAtlasSource

func (self *Extension[T]) AsTileSetAtlasSource() Instance

func (*Extension[T]) AsTileSetSource

func (self *Extension[T]) AsTileSetSource() TileSetSource.Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

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 New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsTileSetAtlasSource

func (self Instance) AsTileSetAtlasSource() Instance

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

func (self Instance) CreateAlternativeTile(atlas_coords Vector2i.XY) 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 (Instance) CreateTile

func (self Instance) CreateTile(atlas_coords Vector2i.XY)

Creates a new tile at coordinates 'atlas_coords' with the given 'size'.

func (Instance) GetAtlasGridSize

func (self Instance) GetAtlasGridSize() Vector2i.XY

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

func (self Instance) GetNextAlternativeTileId(atlas_coords Vector2i.XY) int

Returns the alternative ID a following call to Instance.CreateAlternativeTile would return.

func (Instance) GetRuntimeTexture

func (self Instance) GetRuntimeTexture() Texture2D.Instance

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

func (self Instance) GetTileAnimationColumns(atlas_coords Vector2i.XY) int

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

func (self Instance) GetTileAnimationFramesCount(atlas_coords Vector2i.XY) int

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

func (self Instance) GetTileAnimationSeparation(atlas_coords Vector2i.XY) Vector2i.XY

Returns the separation (as in the atlas grid) between each frame of an animated tile at coordinates 'atlas_coords'.

func (Instance) GetTileAnimationSpeed

func (self Instance) GetTileAnimationSpeed(atlas_coords Vector2i.XY) Float.X

Returns the animation speed of the tile at coordinates 'atlas_coords'.

func (Instance) GetTileAnimationTotalDuration

func (self Instance) GetTileAnimationTotalDuration(atlas_coords Vector2i.XY) Float.X

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

func (self Instance) GetTileAtCoords(atlas_coords Vector2i.XY) Vector2i.XY

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

func (self Instance) GetTileData(atlas_coords Vector2i.XY, alternative_tile int) TileData.Instance

Returns the graphics.gd/classdb/TileData object for the given atlas coordinates and alternative ID.

func (Instance) GetTileSizeInAtlas

func (self Instance) GetTileSizeInAtlas(atlas_coords Vector2i.XY) Vector2i.XY

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

func (self Instance) HasTilesOutsideTexture() bool

Checks if the source has any tiles that don't fit the texture area (either partially or completely).

func (Instance) ID

func (self Instance) ID() ID

func (Instance) Margins

func (self Instance) Margins() Vector2i.XY

func (Instance) MoveTileInAtlas

func (self Instance) MoveTileInAtlas(atlas_coords 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.

func (Instance) RemoveAlternativeTile

func (self Instance) RemoveAlternativeTile(atlas_coords Vector2i.XY, alternative_tile int)

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

func (self Instance) RemoveTile(atlas_coords Vector2i.XY)

Remove a tile and its alternative at coordinates 'atlas_coords'.

func (Instance) Separation

func (self Instance) Separation() Vector2i.XY

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 (self Instance) SetMargins(value Vector2i.XY)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetSeparation

func (self Instance) SetSeparation(value Vector2i.XY)

func (Instance) SetTexture

func (self Instance) SetTexture(value Texture2D.Instance)

func (Instance) SetTextureRegionSize

func (self Instance) SetTextureRegionSize(value Vector2i.XY)

func (Instance) SetTileAnimationColumns

func (self Instance) SetTileAnimationColumns(atlas_coords Vector2i.XY, frame_columns int)

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

func (self Instance) SetTileAnimationFramesCount(atlas_coords Vector2i.XY, frames_count int)

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

func (self Instance) SetTileAnimationSeparation(atlas_coords Vector2i.XY, separation Vector2i.XY)

Sets the margin (in grid tiles) between each tile in the animation layout of the tile at coordinates 'atlas_coords' has.

func (Instance) SetTileAnimationSpeed

func (self Instance) SetTileAnimationSpeed(atlas_coords Vector2i.XY, speed Float.X)

Sets the animation speed of the tile at coordinates 'atlas_coords' has.

func (Instance) SetUseTexturePadding

func (self Instance) SetUseTexturePadding(value bool)

func (Instance) Texture

func (self Instance) Texture() Texture2D.Instance

func (Instance) TextureRegionSize

func (self Instance) TextureRegionSize() Vector2i.XY

func (Instance) UseTexturePadding

func (self Instance) UseTexturePadding() bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL