Ir al contenido principal

PosiciónAnimación

Descripción

Este componente crea una animación sobre una entidad.

Propiedades

PropiedadTipoPor defectoDescripción
objetivoeidindefinidoEl objeto objetivo a animar. Si no se especifica, la animación se ejecuta en el objeto al que está unido el componente.
deXnúmero0La coordenada X inicial de la animación.
deYnúmero0La coordenada Y inicial de la animación.
deZnúmero0La coordenada Z inicial de la animación.
toXnúmero0La coordenada X objetivo de la animación.
toYnúmero0La coordenada Y objetivo de la animación.
toZnúmero0La coordenada Z objetivo de la animación.
autoFrombooleanofalsoSi se activa, ignora las propiedades 'fromX/Y/Z' y anima a partir del estado del objeto al inicio de la animación.
duraciónnúmero1000Duración de la animación en milisegundos.
buclebooleanoverdaderoSi está activada, repite la animación.
invertirbooleanofalsoSi se reproduce en sentido inverso, si se establece el bucle.
easeInbooleanofalsoSi está activada, la función de atenuación se aplicará a lo largo del tiempo en lugar de la interpolación directa.
easeOutbooleanofalsoSi está activada, la función de atenuación se aplicará a lo largo del tiempo en lugar de la interpolación directa.
easingFunctioncadenaCuadráticaElija entre Cuadrático, Cúbico, Cuártico, Quíntico, Sinusoidal, Exponencial, Circular, Elástico, Espalda y Rebote
camino más cortobooleanofalsoSi se activa, la animación tomará el camino más corto hasta completarse.

Funciones

Get

Returns a read-only reference.

Example

ecs.PositionAnimation.get(world, component.eid)

Set

Ensures the component exists on the entity, then assigns the (optional) data to the component.

Example

ecs.PositionAnimation.set(world, component.eid, {
fromX: 0,
fromY: 0,
fromZ: 0,
toX: 0,
toY: 0,
toZ: 0,
autoFrom: false,
duration: 1000,
loop: true,
reverse: false,
easeIn: false,
easeOut: false,
easingFunction: 'Quadratic'
})

Mutate

Perform an update to the component within a callback function. Return true to indicate no changes made.

Example

ecs.PositionAnimation.mutate(world, component.eid, (cursor) => {
cursor.toX = 10;
cursor.toY = 5;
cursor.duration = 2000;
return false;
})

Remove

Removes the component from the entity.

Example

ecs.PositionAnimation.remove(world, component.eid)

Has

Returns true if the component is present on the entity.

Example

ecs.PositionAnimation.has(world, component.eid)

Reset

Adds, or resets the component to its default state.

Example

ecs.PositionAnimation.reset(world, component.eid)

Advanced Functions

Cursor

Returns a mutable reference. Cursors are reused so only one cursor for each component can exist at a time.

Example
ecs.PositionAnimation.cursor(world, component.eid)

Acquire

Same behavior as cursor, but commit must be called after the cursor is done being used.

Example
ecs.PositionAnimation.acquire(world, component.eid)

Commit

Called after acquire. An optional third argument determines whether the cursor was mutated or not.

Example
ecs.PositionAnimation.commit(world, component.eid)
ecs.PositionAnimation.commit(world, component.eid, false)

Dirty

Mark the entity as having been mutated. Only needed in a specific case where systems are mutating data.

Example
ecs.PositionAnimation.dirty(world, component.eid)