[][src]Struct gdnative::api::TileMap

pub struct TileMap { /* fields omitted */ }

core class TileMap inherits Node2D (unsafe).

Official documentation

See the documentation of this class in the Godot engine's official documentation.

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

impl TileMap[src]

Constants

impl TileMap[src]

pub fn new() -> Ref<TileMap, Unique>[src]

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.

pub fn clear(&self)[src]

Clears all cells.

pub fn fix_invalid_tiles(&self)[src]

Clears cells that do not exist in the tileset.

pub fn get_cell(&self, x: i64, y: i64) -> i64[src]

Returns the tile index of the given cell. If no tile exists in the cell, returns [constant INVALID_CELL].

pub fn get_cell_autotile_coord(
    &self,
    x: i64,
    y: i64
) -> Vector2D<f32, UnknownUnit>
[src]

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.

pub fn cell_size(&self) -> Vector2D<f32, UnknownUnit>[src]

The TileMap's cell size.

pub fn get_cellv(&self, position: Vector2D<f32, UnknownUnit>) -> i64[src]

Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns [constant INVALID_CELL].

pub fn clip_uv(&self) -> bool[src]

If [code]true[/code], the cell's UVs will be clipped.

pub fn collision_bounce(&self) -> f64[src]

Bounce value for static body collisions (see [code]collision_use_kinematic[/code]).

pub fn collision_friction(&self) -> f64[src]

Friction value for static body collisions (see [code]collision_use_kinematic[/code]).

pub fn collision_layer(&self) -> i64[src]

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.

pub fn get_collision_layer_bit(&self, bit: i64) -> bool[src]

Returns [code]true[/code] if the given collision layer bit is set.

pub fn collision_mask(&self) -> i64[src]

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.

pub fn get_collision_mask_bit(&self, bit: i64) -> bool[src]

Returns [code]true[/code] if the given collision mask bit is set.

pub fn collision_use_kinematic(&self) -> bool[src]

If [code]true[/code], TileMap collisions will be handled as a kinematic body. If [code]false[/code], collisions will be handled as static body.

pub fn collision_use_parent(&self) -> bool[src]

If [code]true[/code], this tilemap's collision shape will be added to the collision shape of the parent. The parent has to be a [CollisionObject2D].

pub fn custom_transform(&self) -> Transform2D<f32, UnknownUnit, UnknownUnit>[src]

The custom [Transform2D] to be applied to the TileMap's cells.

pub fn half_offset(&self) -> HalfOffset[src]

Amount to offset alternating tiles. See [enum HalfOffset] for possible values.

pub fn mode(&self) -> Mode[src]

The TileMap orientation mode. See [enum Mode] for possible values.

pub fn occluder_light_mask(&self) -> i64[src]

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).

pub fn quadrant_size(&self) -> i64[src]

The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.

pub fn tile_origin(&self) -> TileOrigin[src]

Position for tile origin. See [enum TileOrigin] for possible values.

pub fn tileset(&self) -> Option<Ref<TileSet, Shared>>[src]

The assigned [TileSet].

pub fn get_used_cells(&self) -> VariantArray<Shared>[src]

Returns a [Vector2] array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from [code]-1[/code]).

pub fn get_used_cells_by_id(&self, id: i64) -> VariantArray<Shared>[src]

Returns an array of all cells with the given tile index specified in [code]id[/code].

pub fn get_used_rect(&self) -> Rect<f32, UnknownUnit>[src]

Returns a rectangle enclosing the used (non-empty) tiles of the map.

pub fn is_cell_transposed(&self, x: i64, y: i64) -> bool[src]

Returns [code]true[/code] if the given cell is transposed, i.e. the X and Y axes are swapped.

pub fn is_cell_x_flipped(&self, x: i64, y: i64) -> bool[src]

Returns [code]true[/code] if the given cell is flipped in the X axis.

pub fn is_cell_y_flipped(&self, x: i64, y: i64) -> bool[src]

Returns [code]true[/code] if the given cell is flipped in the Y axis.

pub fn is_centered_textures_enabled(&self) -> bool[src]

If [code]true[/code], 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 [code]false[/code], the texture position start in the top-left corner unless [member compatibility_mode] is enabled.

pub fn is_compatibility_mode_enabled(&self) -> bool[src]

If [code]true[/code], 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 [code]flip_h[/code], [code]flip_v[/code] and [code]transpose[/code] 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 [code]false[/code], the textures do not move when doing [code]flip_h[/code], [code]flip_v[/code] 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.

pub fn is_y_sort_mode_enabled(&self) -> bool[src]

If [code]true[/code], the TileMap's children will be drawn in order of their Y coordinate.

pub fn map_to_world(
    &self,
    map_position: Vector2D<f32, UnknownUnit>,
    ignore_half_ofs: bool
) -> Vector2D<f32, UnknownUnit>
[src]

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

pub fn set_cell(
    &self,
    x: i64,
    y: i64,
    tile: i64,
    flip_x: bool,
    flip_y: bool,
    transpose: bool,
    autotile_coord: Vector2D<f32, UnknownUnit>
)
[src]

Sets the tile index for the cell given by a Vector2.
				An index of [code]-1[/code] 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.
				[b]Note:[/b] 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:
				[codeblock]
				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)
				[/codeblock]

Default Arguments

  • flip_x - false
  • flip_y - false
  • transpose - false
  • autotile_coord - Vector2( 0, 0 )

pub fn set_cell_size(&self, size: Vector2D<f32, UnknownUnit>)[src]

The TileMap's cell size.

pub fn set_cellv(
    &self,
    position: Vector2D<f32, UnknownUnit>,
    tile: i64,
    flip_x: bool,
    flip_y: bool,
    transpose: bool
)
[src]

Sets the tile index for the given cell.
				An index of [code]-1[/code] clears the cell.
				Optionally, the tile can also be flipped or transposed.
				[b]Note:[/b] 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

pub fn set_centered_textures(&self, enable: bool)[src]

If [code]true[/code], 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 [code]false[/code], the texture position start in the top-left corner unless [member compatibility_mode] is enabled.

pub fn set_clip_uv(&self, enable: bool)[src]

If [code]true[/code], the cell's UVs will be clipped.

pub fn set_collision_bounce(&self, value: f64)[src]

Bounce value for static body collisions (see [code]collision_use_kinematic[/code]).

pub fn set_collision_friction(&self, value: f64)[src]

Friction value for static body collisions (see [code]collision_use_kinematic[/code]).

pub fn set_collision_layer(&self, layer: i64)[src]

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.

pub fn set_collision_layer_bit(&self, bit: i64, value: bool)[src]

Sets the given collision layer bit.

pub fn set_collision_mask(&self, mask: i64)[src]

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.

pub fn set_collision_mask_bit(&self, bit: i64, value: bool)[src]

Sets the given collision mask bit.

pub fn set_collision_use_kinematic(&self, use_kinematic: bool)[src]

If [code]true[/code], TileMap collisions will be handled as a kinematic body. If [code]false[/code], collisions will be handled as static body.

pub fn set_collision_use_parent(&self, use_parent: bool)[src]

If [code]true[/code], this tilemap's collision shape will be added to the collision shape of the parent. The parent has to be a [CollisionObject2D].

pub fn set_compatibility_mode(&self, enable: bool)[src]

If [code]true[/code], 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 [code]flip_h[/code], [code]flip_v[/code] and [code]transpose[/code] 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 [code]false[/code], the textures do not move when doing [code]flip_h[/code], [code]flip_v[/code] 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.

pub fn set_custom_transform(
    &self,
    custom_transform: Transform2D<f32, UnknownUnit, UnknownUnit>
)
[src]

The custom [Transform2D] to be applied to the TileMap's cells.

pub fn set_half_offset(&self, half_offset: i64)[src]

Amount to offset alternating tiles. See [enum HalfOffset] for possible values.

pub fn set_mode(&self, mode: i64)[src]

The TileMap orientation mode. See [enum Mode] for possible values.

pub fn set_occluder_light_mask(&self, mask: i64)[src]

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).

pub fn set_quadrant_size(&self, size: i64)[src]

The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.

pub fn set_tile_origin(&self, origin: i64)[src]

Position for tile origin. See [enum TileOrigin] for possible values.

pub fn set_tileset(&self, tileset: impl AsArg<TileSet>)[src]

The assigned [TileSet].

pub fn set_y_sort_mode(&self, enable: bool)[src]

If [code]true[/code], the TileMap's children will be drawn in order of their Y coordinate.

pub fn update_bitmask_area(&self, position: Vector2D<f32, UnknownUnit>)[src]

Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates.

pub fn update_bitmask_region(
    &self,
    start: Vector2D<f32, UnknownUnit>,
    end: Vector2D<f32, UnknownUnit>
)
[src]

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 )

pub fn update_dirty_quadrants(&self)[src]

Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified.

pub fn world_to_map(
    &self,
    world_position: Vector2D<f32, UnknownUnit>
) -> Vector2D<f32, UnknownUnit>
[src]

Returns the tilemap (grid-based) coordinates corresponding to the given local position.

Methods from Deref<Target = Node2D>

pub fn apply_scale(&self, ratio: Vector2D<f32, UnknownUnit>)[src]

Multiplies the current scale by the [code]ratio[/code] vector.

pub fn get_angle_to(&self, point: Vector2D<f32, UnknownUnit>) -> f64[src]

Returns the angle between the node and the [code]point[/code] in radians.

pub fn global_position(&self) -> Vector2D<f32, UnknownUnit>[src]

Global position.

pub fn global_rotation(&self) -> f64[src]

Global rotation in radians.

pub fn global_rotation_degrees(&self) -> f64[src]

Global rotation in degrees.

pub fn global_scale(&self) -> Vector2D<f32, UnknownUnit>[src]

Global scale.

pub fn position(&self) -> Vector2D<f32, UnknownUnit>[src]

Position, relative to the node's parent.

pub fn get_relative_transform_to_parent(
    &self,
    parent: impl AsArg<Node>
) -> Transform2D<f32, UnknownUnit, UnknownUnit>
[src]

Returns the [Transform2D] relative to this node's parent.

pub fn rotation(&self) -> f64[src]

Rotation in radians, relative to the node's parent.

pub fn rotation_degrees(&self) -> f64[src]

Rotation in degrees, relative to the node's parent.

pub fn scale(&self) -> Vector2D<f32, UnknownUnit>[src]

The node's scale. Unscaled value: [code](1, 1)[/code].

pub fn z_index(&self) -> i64[src]

Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.

pub fn global_translate(&self, offset: Vector2D<f32, UnknownUnit>)[src]

Adds the [code]offset[/code] vector to the node's global position.

pub fn is_z_relative(&self) -> bool[src]

If [code]true[/code], 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.

pub fn look_at(&self, point: Vector2D<f32, UnknownUnit>)[src]

Rotates the node so it points towards the [code]point[/code], which is expected to use global coordinates.

pub fn move_local_x(&self, delta: f64, scaled: bool)[src]

Applies a local translation on the node's X axis based on the [method Node._process]'s [code]delta[/code]. If [code]scaled[/code] is [code]false[/code], normalizes the movement.

Default Arguments

  • scaled - false

pub fn move_local_y(&self, delta: f64, scaled: bool)[src]

Applies a local translation on the node's Y axis based on the [method Node._process]'s [code]delta[/code]. If [code]scaled[/code] is [code]false[/code], normalizes the movement.

Default Arguments

  • scaled - false

pub fn rotate(&self, radians: f64)[src]

Applies a rotation to the node, in radians, starting from its current rotation.

pub fn set_global_position(&self, position: Vector2D<f32, UnknownUnit>)[src]

Global position.

pub fn set_global_rotation(&self, radians: f64)[src]

Global rotation in radians.

pub fn set_global_rotation_degrees(&self, degrees: f64)[src]

Global rotation in degrees.

pub fn set_global_scale(&self, scale: Vector2D<f32, UnknownUnit>)[src]

Global scale.

pub fn set_global_transform(
    &self,
    xform: Transform2D<f32, UnknownUnit, UnknownUnit>
)
[src]

Global [Transform2D].

pub fn set_position(&self, position: Vector2D<f32, UnknownUnit>)[src]

Position, relative to the node's parent.

pub fn set_rotation(&self, radians: f64)[src]

Rotation in radians, relative to the node's parent.

pub fn set_rotation_degrees(&self, degrees: f64)[src]

Rotation in degrees, relative to the node's parent.

pub fn set_scale(&self, scale: Vector2D<f32, UnknownUnit>)[src]

The node's scale. Unscaled value: [code](1, 1)[/code].

pub fn set_transform(&self, xform: Transform2D<f32, UnknownUnit, UnknownUnit>)[src]

Local [Transform2D].

pub fn set_z_as_relative(&self, enable: bool)[src]

If [code]true[/code], 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.

pub fn set_z_index(&self, z_index: i64)[src]

Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.

pub fn to_global(
    &self,
    local_point: Vector2D<f32, UnknownUnit>
) -> Vector2D<f32, UnknownUnit>
[src]

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.

pub fn to_local(
    &self,
    global_point: Vector2D<f32, UnknownUnit>
) -> Vector2D<f32, UnknownUnit>
[src]

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.

pub fn translate(&self, offset: Vector2D<f32, UnknownUnit>)[src]

Translates the node by the given [code]offset[/code] in local coordinates.

Trait Implementations

impl Debug for TileMap[src]

impl Deref for TileMap[src]

type Target = Node2D

The resulting type after dereferencing.

impl DerefMut for TileMap[src]

impl GodotObject for TileMap[src]

type RefKind = ManuallyManaged

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

impl Instanciable for TileMap[src]

impl QueueFree for TileMap[src]

impl SubClass<CanvasItem> for TileMap[src]

impl SubClass<Node> for TileMap[src]

impl SubClass<Node2D> for TileMap[src]

impl SubClass<Object> for TileMap[src]

Auto Trait Implementations

impl RefUnwindSafe for TileMap

impl !Send for TileMap

impl !Sync for TileMap

impl Unpin for TileMap

impl UnwindSafe for TileMap

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.