TileSetAtlasSource

package
v0.0.0-...-af89a4c Latest Latest
Warning

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

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

Documentation

Overview

Package TileSetAtlasSource provides methods for working with TileSetAtlasSource object instances.

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 [param atlas_coords]. If [param 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 [param alternative_id_override].

func (Expanded) CreateTile

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

Creates a new tile at coordinates [param atlas_coords] with the given [param 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 [param 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 [param 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 [param atlas_coords] coordinates to the [param new_atlas_coords] coordinates with the [param new_size] size. This functions will fail if a tile is already present in the given area. If [param new_atlas_coords] is [code]Vector2i(-1, -1)[/code], keeps the tile's coordinates. If [param new_size] is [code]Vector2i(-1, -1)[/code], keeps the tile's size. To avoid an error, first check if a move is possible using [method has_room_for_tile].

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

An atlas is a grid of tiles laid out on a texture. Each tile in the grid must be exposed using [method create_tile]. 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 [method create_alternative_tile], 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 [TileSet] layers. Those properties are stored in a TileData object that can be accessed and modified using [method get_tile_data]. As TileData properties are stored directly in the TileSetAtlasSource resource, their properties might also be set using [code]TileSetAtlasSource.set("<coords_x>:<coords_y>/<alternative_id>/<tile_data_property>")[/code].

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 [method has_tiles_outside_texture] beforehand.

func (Instance) CreateAlternativeTile

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

Creates an alternative tile for the tile at coordinates [param atlas_coords]. If [param 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 [param alternative_id_override].

func (Instance) CreateTile

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

Creates a new tile at coordinates [param atlas_coords] with the given [param 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 [member texture]'s size, the atlas [member margins], and the tiles' [member texture_region_size].

func (Instance) GetNextAlternativeTileId

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

Returns the alternative ID a following call to [method create_alternative_tile] would return.

func (Instance) GetRuntimeTexture

func (self Instance) GetRuntimeTexture() Texture2D.Instance

If [member use_texture_padding] is [code]false[/code], returns [member texture]. Otherwise, returns and internal [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 [param atlas_coords] for the given [param frame] inside the texture returned by [method get_runtime_texture]. [b]Note:[/b] If [member use_texture_padding] is [code]false[/code], returns the same as [method get_tile_texture_region].

func (Instance) GetTileAnimationColumns

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

Returns how many columns the tile at [param 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 [param frame_index] for the tile at coordinates [param atlas_coords].

func (Instance) GetTileAnimationFramesCount

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

Returns how many animation frames has the tile at coordinates [param atlas_coords].

func (Instance) GetTileAnimationMode

func (self Instance) GetTileAnimationMode(atlas_coords Vector2i.XY) TileAnimationMode

Returns the tile animation mode of the tile at [param atlas_coords]. See also [method set_tile_animation_mode].

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 [param atlas_coords].

func (Instance) GetTileAnimationSpeed

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

Returns the animation speed of the tile at coordinates [param 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 [param 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 [param atlas_coords] coordinates, returns the top-left coordinates of the tile (thus its coordinate ID). Returns [code]Vector2i(-1, -1)[/code] otherwise.

func (Instance) GetTileData

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

Returns the [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 [param 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 [param 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: [param texture], [param margins], [param separation] or [param 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 [param 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 [param atlas_coords] coordinates to the [param new_atlas_coords] coordinates with the [param new_size] size. This functions will fail if a tile is already present in the given area. If [param new_atlas_coords] is [code]Vector2i(-1, -1)[/code], keeps the tile's coordinates. If [param new_size] is [code]Vector2i(-1, -1)[/code], keeps the tile's size. To avoid an error, first check if a move is possible using [method has_room_for_tile].

func (Instance) RemoveAlternativeTile

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

Remove a tile's alternative with alternative ID [param alternative_tile]. Calling this function with [param 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 [param 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 [param alternative_tile] to [param new_id]. Calling this function with [param 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 [param 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 [param duration] of frame [param frame_index] for the tile at coordinates [param 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 [param 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 [param atlas_coords] to [param mode]. See also [method get_tile_animation_mode].

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 [param 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 [param 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 [enum TileAnimationMode] enum.*/
	TileAnimationModeMax TileAnimationMode = 2
)

Jump to

Keyboard shortcuts

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