Struct gdnative_bindings_lily::TileMap [−][src]
pub struct TileMap { /* fields omitted */ }
Expand description
core class TileMap
inherits Node2D
(unsafe).
Official documentation
See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.
Memory management
Non reference counted objects such as the ones of this type are usually owned by the engine.
TileMap
is a reference-only type. Persistent references can
only exist in the unsafe Ref<TileMap>
form.
In the cases where Rust code owns an object of this type, for example if the object was just
created on the Rust side and not passed to the engine yet, ownership should be either given
to the engine or the object must be manually destroyed using Ref::free
, or Ref::queue_free
if it is a Node
.
Class hierarchy
TileMap inherits methods from:
Safety
All types in the Godot API have “interior mutability” in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Implementations
Constants
Creates a new instance of this object.
Because this type is not reference counted, the lifetime of the returned object is not automatically managed.
Immediately after creation, the object is owned by the caller, and can be
passed to the engine (in which case the engine will be responsible for
destroying the object) or destroyed manually using Ref::free
, or preferably
Ref::queue_free
if it is a Node
.
Clears cells that do not exist in the tileset.
Returns the tile index of the given cell. If no tile exists in the cell, returns [constant INVALID_CELL].
Returns the coordinate (subtile column and row) of the autotile variation in the tileset. Returns a zero vector if the cell doesn’t have autotiling.
Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns [constant INVALID_CELL].
Bounce value for static body collisions (see collision_use_kinematic
).
Friction value for static body collisions (see collision_use_kinematic
).
The collision layer(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
Returns true
if the given collision layer bit is set.
The collision mask(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
Returns true
if the given collision mask bit is set.
If true
, TileMap collisions will be handled as a kinematic body. If false
, collisions will be handled as static body.
If true
, this tilemap’s collision shape will be added to the collision shape of the parent. The parent has to be a CollisionObject2D.
The custom Transform2D to be applied to the TileMap’s cells.
Amount to offset alternating tiles. See [enum HalfOffset] for possible values.
The light mask assigned to all light occluders in the TileMap. The TileSet’s light occluders will cast shadows only from Light2D(s) that have the same light mask(s).
The TileMap’s quadrant size. Optimizes drawing by batching, using chunks of this size.
Position for tile origin. See [enum TileOrigin] for possible values.
Returns a Vector2 array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from -1
).
Returns an array of all cells with the given tile index specified in id
.
Returns a rectangle enclosing the used (non-empty) tiles of the map.
Returns true
if the given cell is transposed, i.e. the X and Y axes are swapped.
Returns true
if the given cell is flipped in the X axis.
Returns true
if the given cell is flipped in the Y axis.
If true
, the textures will be centered in the middle of each tile. This is useful for certain isometric or top-down modes when textures are made larger or smaller than the tiles (e.g. to avoid flickering on tile edges). The offset is still applied, but from the center of the tile. If used, [member compatibility_mode] is ignored.
If false
, the texture position start in the top-left corner unless [member compatibility_mode] is enabled.
If true
, the compatibility with the tilemaps made in Godot 3.1 or earlier is maintained (textures move when the tile origin changes and rotate if the texture size is not homogeneous). This mode presents problems when doing flip_h
, flip_v
and transpose
tile operations on non-homogeneous isometric tiles (e.g. 2:1), in which the texture could not coincide with the collision, thus it is not recommended for isometric or non-square tiles.
If false
, the textures do not move when doing flip_h
, flip_v
operations if no offset is used, nor when changing the tile origin.
The compatibility mode doesn’t work with the [member centered_textures] option, because displacing textures with the [member cell_tile_origin] option or in irregular tiles is not relevant when centering those textures.
If true
, the TileMap’s children will be drawn in order of their Y coordinate.
Returns the global position corresponding to the given tilemap (grid-based) coordinates. Optionally, the tilemap’s half offset can be ignored.
Default Arguments
ignore_half_ofs
-false
Sample code is GDScript unless otherwise noted.
Sets the tile index for the cell given by a Vector2.
An index of -1
clears the cell.
Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile.
Note: Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
If you need these to be immediately updated, you can call [method update_dirty_quadrants].
Overriding this method also overrides it internally, allowing custom logic to be implemented when tiles are placed/removed:
func set_cell(x, y, tile, flip_x=false, flip_y=false, transpose=false, autotile_coord=Vector2())
# Write your custom logic here.
# To call the default method:
.set_cell(x, y, tile, flip_x, flip_y, transpose, autotile_coord)
Default Arguments
flip_x
-false
flip_y
-false
transpose
-false
autotile_coord
-Vector2( 0, 0 )
The TileMap’s cell size.
Sets the tile index for the given cell.
An index of -1
clears the cell.
Optionally, the tile can also be flipped or transposed.
Note: Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
If you need these to be immediately updated, you can call [method update_dirty_quadrants].
Default Arguments
flip_x
-false
flip_y
-false
transpose
-false
If true
, the textures will be centered in the middle of each tile. This is useful for certain isometric or top-down modes when textures are made larger or smaller than the tiles (e.g. to avoid flickering on tile edges). The offset is still applied, but from the center of the tile. If used, [member compatibility_mode] is ignored.
If false
, the texture position start in the top-left corner unless [member compatibility_mode] is enabled.
If true
, the cell’s UVs will be clipped.
Bounce value for static body collisions (see collision_use_kinematic
).
Friction value for static body collisions (see collision_use_kinematic
).
The collision layer(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
Sets the given collision layer bit.
The collision mask(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
Sets the given collision mask bit.
If true
, TileMap collisions will be handled as a kinematic body. If false
, collisions will be handled as static body.
If true
, this tilemap’s collision shape will be added to the collision shape of the parent. The parent has to be a CollisionObject2D.
If true
, the compatibility with the tilemaps made in Godot 3.1 or earlier is maintained (textures move when the tile origin changes and rotate if the texture size is not homogeneous). This mode presents problems when doing flip_h
, flip_v
and transpose
tile operations on non-homogeneous isometric tiles (e.g. 2:1), in which the texture could not coincide with the collision, thus it is not recommended for isometric or non-square tiles.
If false
, the textures do not move when doing flip_h
, flip_v
operations if no offset is used, nor when changing the tile origin.
The compatibility mode doesn’t work with the [member centered_textures] option, because displacing textures with the [member cell_tile_origin] option or in irregular tiles is not relevant when centering those textures.
The custom Transform2D to be applied to the TileMap’s cells.
Amount to offset alternating tiles. See [enum HalfOffset] for possible values.
The TileMap orientation mode. See [enum Mode] for possible values.
The light mask assigned to all light occluders in the TileMap. The TileSet’s light occluders will cast shadows only from Light2D(s) that have the same light mask(s).
The TileMap’s quadrant size. Optimizes drawing by batching, using chunks of this size.
Position for tile origin. See [enum TileOrigin] for possible values.
The assigned TileSet.
If true
, the TileMap’s children will be drawn in order of their Y coordinate.
Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates.
Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates). Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap.
Default Arguments
start
-Vector2( 0, 0 )
end
-Vector2( 0, 0 )
Updates the tile map’s quadrants, allowing things such as navigation and collision shapes to be immediately used if modified.
Returns the tilemap (grid-based) coordinates corresponding to the given local position.
Methods from Deref<Target = Node2D>
Multiplies the current scale by the ratio
vector.
Returns the angle between the node and the point
in radians.
Global position.
Global rotation in radians.
Global rotation in degrees.
Global scale.
Returns the Transform2D relative to this node’s parent.
Rotation in degrees, relative to the node’s parent.
Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.
Adds the offset
vector to the node’s global position.
If true
, the node’s Z index is relative to its parent’s Z index. If this node’s Z index is 2 and its parent’s effective Z index is 3, then this node’s effective Z index will be 2 + 3 = 5.
Rotates the node so it points towards the point
, which is expected to use global coordinates.
Applies a local translation on the node’s X axis based on the [method Node._process]’s delta
. If scaled
is false
, normalizes the movement.
Default Arguments
scaled
-false
Applies a local translation on the node’s Y axis based on the [method Node._process]’s delta
. If scaled
is false
, normalizes the movement.
Default Arguments
scaled
-false
Applies a rotation to the node, in radians, starting from its current rotation.
Global position.
Global rotation in radians.
Global rotation in degrees.
Global scale.
Global Transform2D.
Position, relative to the node’s parent.
Rotation in radians, relative to the node’s parent.
Rotation in degrees, relative to the node’s parent.
Local Transform2D.
If true
, the node’s Z index is relative to its parent’s Z index. If this node’s Z index is 2 and its parent’s effective Z index is 3, then this node’s effective Z index will be 2 + 3 = 5.
Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.
Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the Node2D it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node’s own position will give an incorrect result, as it will incorporate the node’s own transformation into its global position.
Transforms the provided global position into a position in local coordinate space. The output will be local relative to the Node2D it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent.
Trait Implementations
type RefKind = ManuallyManaged
type RefKind = ManuallyManaged
Creates an explicitly null reference of Self
as a method argument. This makes type
inference easier for the compiler compared to Option
. Read more
Creates a new instance of Self
using a zero-argument constructor, as a Unique
reference. Read more
Performs a dynamic reference downcast to target type. Read more
Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more
Creates a persistent reference to the same Godot object with shared thread access. Read more
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
Creates a persistent reference to the same Godot object with thread-local thread access. Read more
Creates a persistent reference to the same Godot object with unique access. Read more
Recovers a instance ID previously returned by Object::get_instance_id
if the object is
still alive. See also TRef::try_from_instance_id
. Read more
Auto Trait Implementations
impl RefUnwindSafe for TileMap
impl UnwindSafe for TileMap