[][src]Struct gdnative::api::AnimatedTexture

pub struct AnimatedTexture { /* fields omitted */ }

core class AnimatedTexture inherits Texture (reference counted).

Official documentation

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

Memory management

The lifetime of this object is automatically managed through reference counting.

Class hierarchy

AnimatedTexture 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 AnimatedTexture[src]

Constants

pub const MAX_FRAMES: i64[src]

impl AnimatedTexture[src]

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

Creates a new instance of this object.

This is a reference-counted type. The returned object is automatically managed by Ref.

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

Sets the currently visible frame of the texture.

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

Animation speed in frames per second. This value defines the default time interval between two frames of the animation, and thus the overall duration of the animation loop based on the [member frames] property. A value of 0 means no predefined number of frames per second, the animation will play according to each frame's frame delay (see [method set_frame_delay]).
			For example, an animation with 8 frames, no frame delay and a [code]fps[/code] value of 2 will run for 4 seconds, with each frame lasting 0.5 seconds.

pub fn frame_delay(&self, frame: i64) -> f64[src]

Returns the given frame's delay value.

pub fn frame_texture(&self, frame: i64) -> Option<Ref<Texture, Shared>>[src]

Returns the given frame's [Texture].

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

Number of frames to use in the animation. While you can create the frames independently with [method set_frame_texture], you need to set this value for the animation to take new frames into account. The maximum number of frames is [constant MAX_FRAMES].

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

If [code]true[/code], the animation will only play once and will not loop back to the first frame after reaching the end. Note that reaching the end will not set [member pause] to [code]true[/code].

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

If [code]true[/code], the animation will pause where it currently is (i.e. at [member current_frame]). The animation will continue from where it was paused when changing this property to [code]false[/code].

pub fn set_current_frame(&self, frame: i64)[src]

Sets the currently visible frame of the texture.

pub fn set_fps(&self, fps: f64)[src]

Animation speed in frames per second. This value defines the default time interval between two frames of the animation, and thus the overall duration of the animation loop based on the [member frames] property. A value of 0 means no predefined number of frames per second, the animation will play according to each frame's frame delay (see [method set_frame_delay]).
			For example, an animation with 8 frames, no frame delay and a [code]fps[/code] value of 2 will run for 4 seconds, with each frame lasting 0.5 seconds.

pub fn set_frame_delay(&self, frame: i64, delay: f64)[src]

Sets an additional delay (in seconds) between this frame and the next one, that will be added to the time interval defined by [member fps]. By default, frames have no delay defined. If a delay value is defined, the final time interval between this frame and the next will be [code]1.0 / fps + delay[/code].
				For example, for an animation with 3 frames, 2 FPS and a frame delay on the second frame of 1.2, the resulting playback will be:
				[codeblock]
				Frame 0: 0.5 s (1 / fps)
				Frame 1: 1.7 s (1 / fps + 1.2)
				Frame 2: 0.5 s (1 / fps)
				Total duration: 2.7 s
				[/codeblock]

pub fn set_frame_texture(&self, frame: i64, texture: impl AsArg<Texture>)[src]

Assigns a [Texture] to the given frame. Frame IDs start at 0, so the first frame has ID 0, and the last frame of the animation has ID [member frames] - 1.
				You can define any number of textures up to [constant MAX_FRAMES], but keep in mind that only frames from 0 to [member frames] - 1 will be part of the animation.

pub fn set_frames(&self, frames: i64)[src]

Number of frames to use in the animation. While you can create the frames independently with [method set_frame_texture], you need to set this value for the animation to take new frames into account. The maximum number of frames is [constant MAX_FRAMES].

pub fn set_oneshot(&self, oneshot: bool)[src]

If [code]true[/code], the animation will only play once and will not loop back to the first frame after reaching the end. Note that reaching the end will not set [member pause] to [code]true[/code].

pub fn set_pause(&self, pause: bool)[src]

If [code]true[/code], the animation will pause where it currently is (i.e. at [member current_frame]). The animation will continue from where it was paused when changing this property to [code]false[/code].

Methods from Deref<Target = Texture>

pub fn draw(
    &self,
    canvas_item: Rid,
    position: Vector2D<f32, UnknownUnit>,
    modulate: Color,
    transpose: bool,
    normal_map: impl AsArg<Texture>
)
[src]

Draws the texture using a [CanvasItem] with the [VisualServer] API at the specified [code]position[/code]. Equivalent to [method VisualServer.canvas_item_add_texture_rect] with a rect at [code]position[/code] and the size of this [Texture].

Default Arguments

  • modulate - Color( 1, 1, 1, 1 )
  • transpose - false
  • normal_map - null

pub fn draw_rect(
    &self,
    canvas_item: Rid,
    rect: Rect<f32, UnknownUnit>,
    tile: bool,
    modulate: Color,
    transpose: bool,
    normal_map: impl AsArg<Texture>
)
[src]

Draws the texture using a [CanvasItem] with the [VisualServer] API. Equivalent to [method VisualServer.canvas_item_add_texture_rect].

Default Arguments

  • modulate - Color( 1, 1, 1, 1 )
  • transpose - false
  • normal_map - null

pub fn draw_rect_region(
    &self,
    canvas_item: Rid,
    rect: Rect<f32, UnknownUnit>,
    src_rect: Rect<f32, UnknownUnit>,
    modulate: Color,
    transpose: bool,
    normal_map: impl AsArg<Texture>,
    clip_uv: bool
)
[src]

Draws a part of the texture using a [CanvasItem] with the [VisualServer] API. Equivalent to [method VisualServer.canvas_item_add_texture_rect_region].

Default Arguments

  • modulate - Color( 1, 1, 1, 1 )
  • transpose - false
  • normal_map - null
  • clip_uv - true

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

Returns an [Image] that is a copy of data from this [Texture]. [Image]s can be accessed and manipulated directly.

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

The texture's [enum Flags]. [enum Flags] are used to set various properties of the [Texture].

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

Returns the texture height.

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

Returns the texture size.

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

Returns the texture width.

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

Returns [code]true[/code] if this [Texture] has an alpha channel.

pub fn set_flags(&self, flags: i64)[src]

The texture's [enum Flags]. [enum Flags] are used to set various properties of the [Texture].

Trait Implementations

impl Debug for AnimatedTexture[src]

impl Deref for AnimatedTexture[src]

type Target = Texture

The resulting type after dereferencing.

impl DerefMut for AnimatedTexture[src]

impl GodotObject for AnimatedTexture[src]

type RefKind = RefCounted

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 AnimatedTexture[src]

impl SubClass<Object> for AnimatedTexture[src]

impl SubClass<Reference> for AnimatedTexture[src]

impl SubClass<Resource> for AnimatedTexture[src]

impl SubClass<Texture> for AnimatedTexture[src]

Auto Trait Implementations

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.