AnimatedTexture

Inherits: Texture < Resource < Reference < Object

Textura de conexión para animaciones simples basadas en fotogramas.

Descripción

AnimatedTexture is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike AnimationPlayer or AnimatedSprite, it isn't a Node, but has the advantage of being usable anywhere a Texture resource can be used, e.g. in a TileSet.

The playback of the animation is controlled by the fps property as well as each frame's optional delay (see set_frame_delay). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame.

AnimatedTexture currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.

Note: AnimatedTexture doesn't support using AtlasTextures. Each frame needs to be a separate Texture.

Propiedades

int

current_frame

int

flags

0 (overrides Texture)

float

fps

4.0

int

frames

1

bool

oneshot

false

bool

pause

false

Métodos

float

get_frame_delay ( int frame ) const

Texture

get_frame_texture ( int frame ) const

void

set_frame_delay ( int frame, float delay )

void

set_frame_texture ( int frame, Texture texture )

Constantes

  • MAX_FRAMES = 256 --- The maximum number of frames supported by AnimatedTexture. If you need more frames in your animation, use AnimationPlayer or AnimatedSprite.

Descripciones de Propiedades

  • int current_frame

Setter

set_current_frame(value)

Getter

get_current_frame()

Establece el fotograma actualmente visible de la textura.


Default

4.0

Setter

set_fps(value)

Getter

get_fps()

Velocidad de animación en fotogramas por segundo. Este valor define el intervalo de tiempo por defecto entre dos fotogramas de la animación, y por lo tanto la duración total del bucle de animación basado en la propiedad frames. Un valor de 0 significa que no hay un número predefinido de fotogramas por segundo, la animación se reproducirá de acuerdo con el retardo de fotogramas de cada fotograma (ver set_frame_delay).

Por ejemplo, una animación con 8 fotogramas, sin retardo de fotograma y un valor fps de 2 se ejecutará durante 4 segundos, y cada fotograma durará 0,5 segundos.


Default

1

Setter

set_frames(value)

Getter

get_frames()

Número de fotogramas a usar en la animación. Aunque puedes crear los fotogramas independientemente con set_frame_texture, necesitas establecer este valor para que la animación tenga en cuenta los nuevos fotogramas. El número máximo de fotogramas es MAX_FRAMES.


Default

false

Setter

set_oneshot(value)

Getter

get_oneshot()

Si true, la animación sólo se reproducirá una vez y no volverá al primer fotograma después de llegar al final. Ten en cuenta que al llegar al final no se establecerá pause en true.


Default

false

Setter

set_pause(value)

Getter

get_pause()

Si true, la animación se detendrá donde se encuentra actualmente (es decir, en current_frame). La animación continuará desde donde se detuvo al cambiar esta propiedad a false.

Descripciones de Métodos

  • float get_frame_delay ( int frame ) const

Devuelve el valor de retardo del fotograma dado.


Returns the given frame's Texture.


  • void set_frame_delay ( int frame, float delay )

Establece un retardo adicional (en segundos) entre este fotograma y el siguiente, que se añadirá al intervalo de tiempo definido por fps. Por defecto, los fotogramas no tienen definido ningún retardo. Si se define un valor de retardo, el intervalo de tiempo final entre este fotograma y el siguiente será de 1.0 / fps + retardo.

Por ejemplo, para una animación con 3 cuadros, 2 FPS y un retardo de fotograma en el segundo cuadro de 1.2, la reproducción resultante será:

Fotograma 0: 0.5 s (1 / fps)
Fotograma 1: 1.7 s (1 / fps + 1.2)
Fotograma 2: 0.5 s (1 / fps)
Duración Total : 2.7 segundos

  • void set_frame_texture ( int frame, Texture texture )

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 frames - 1.

You can define any number of textures up to MAX_FRAMES, but keep in mind that only frames from 0 to frames - 1 will be part of the animation.