¶
luxe
API (2025.1.2
)¶
luxe: system/anim.modifier
module¶
Anim¶
import "luxe: system/anim.modifier" for Anim
Anim
is an animation player attached to an entity.It plays animations from animation assets or ones created from code. Animations can target the entity
Anim
is attached to, but can target any entity. For example, a level cutscene could be played back from one entity, but it drives several other entities. From assets like scenes and prototypes,Anim
provides an autoplay list, for playing when loaded.You can play multiple animations at the same time, for example, the player might have a walk animation playing and you play a glowing animation on top.
Anim
supports curve, linear and discrete driven animations and is expanded on by World Systems that provide animation tracks.
- create(entity:
Entity
) - destroy(entity:
Entity
) - has(entity:
Entity
) - valid(entity:
Entity
, anim:Anim
) - get_source_id(entity:
Entity
, anim:Anim
) - get_state(entity:
Entity
, anim:Anim
) - get_active_anims(entity:
Entity
) - play(entity:
Entity
, anim_lx:ID
, time_offset:Num
) - blend(entity:
Entity
, anim_lx:ID
, blend_time:Num
, time_offset:Num
) - play(entity:
Entity
, anim_lx:ID
) - blend(entity:
Entity
, anim_lx:ID
, blend_time:Num
) - play_only(entity:
Entity
, anim_lx:ID
, time_offset:Num
) - play_only(entity:
Entity
, anim_lx:ID
) - stop(entity:
Entity
, anim:Anim
, reset:Bool
) - stop(entity:
Entity
, anim:Anim
) - stop_all(entity:
Entity
, reset:Bool
) - stop_all(entity:
Entity
) - create_track(entity:
Entity
, anim:Anim
, track_id:Any
, track_type:Any
) - has_track(entity:
Entity
, anim:Anim
, track_id:Any
) - track_set_range(entity:
Entity
, anim:Anim
, track_id:Any
, min:Any
, max:Any
) - track_get_range(entity:
Entity
, anim:Anim
, track_id:Any
) - track_set(entity:
Entity
, anim:Anim
, track_id:Any
, property:Any
, value:Any
) - track_set_channel(entity:
Entity
, anim:Anim
, track_id:Any
, channel_id:Any
, channel_idx:Any
, interp:Any
, keys:Any
) - set_play_count(entity:
Entity
, anim:Anim
, play_count:Num
) - set_rate(entity:
Entity
, anim:Anim
, rate:Num
) - set_start(entity:
Entity
, anim:Anim
, start:Num
) - set_end(entity:
Entity
, anim:Anim
, end:Num
) - set_interval_time(entity:
Entity
, anim:Anim
, time:Num
) - get_play_count(entity:
Entity
, anim:Anim
) - get_rate(entity:
Entity
, anim:Anim
) - get_duration(entity:
Entity
, anim:Anim
) - get_start(entity:
Entity
, anim:Anim
) - get_end(entity:
Entity
, anim:Anim
) - get_interval_time(entity:
Entity
, anim:Anim
) - on_event(entity:
Entity
, anim:Anim
, fn:Fn
)
Entity
)
¶unknown
Attach an
Anim
modifier toentity
.var entity = Entity.create(world) Anim.create(entity)
Entity
)
¶None
Detach and destroy the
Anim
attached toentity
.Anim.destroy(entity)
Entity
)
¶Bool
Returns whether
entity
has anAnim
modifier attached.if(Anim.has(entity)) { Log.print("found anim") }
Entity
, anim: Anim
)
¶Bool
Returns whether the
Anim
instance is valid for theAnim
attached toentity
.var anim = Anim.play(entity, "player/idle") if(!Anim.valid(entity, anim)) { Log.print("oh no!") }
Entity
, anim: Anim
)
¶ID
Returns the
ID
of the animation asset that theAnim
instance was played from, if known, by asking theAnim
attached toentity
. Returnsnull
if not.var anim = Anim.play(entity, "player/idle") var source_id = Anim.get_source_id(entity, anim) Log.print(Strings.get(source_id)) //expect: "player/idle"
Entity
, anim: Anim
)
¶AnimState
Return the animation state of the
Anim
instance, by asking theAnim
attached toentity
.var anim = Anim.play(entity, "player/idle") var state = Anim.get_state(entity, anim) if(state == AnimState.playing) { Anim.stop(entity, anim) }
Entity
)
¶List
Returns a list of
Anim
instances that are active on theAnim
attached toentity
.var active = Anim.get_active_anims(entity) for(anim in active) { var state = Anim.get_state(entity, anim) Log.print(AnimState.name(state)); }
Entity
, anim_lx: ID
, time_offset: Num
)
¶Anim
Play the animation asset
anim_lx
on the Anim attached toentity
. Thetime_offset
is a time in seconds to begin playback from. For example, you might pause an animation and hold onto the animation time when it was paused. Then when resuming, you can play from the new time. Returns the newly startedAnim
instance.var anim = Anim.play(entity, "player/idle", 0.5)
Entity
, anim_lx: ID
, blend_time: Num
, time_offset: Num
)
¶Anim
Play the animation asset
anim_lx
on theAnim
attached toentity
with a blend fade time. Thetime_offset
is a time in seconds to begin playback from. Theblend_time
is handled by some tracks, not all. Returns the newly startedAnim
instance.//fade in the animation over 0.6 seconds var anim = Anim.blend(entity, "player/idle", 0.6)
Entity
, anim_lx: ID
)
¶Anim
Play the animation asset
anim_lx
on theAnim
attached toentity
. Plays from the beginning. Returns the newly startedAnim
instance.var anim = Anim.play(entity, "player/idle")
Entity
, anim_lx: ID
, blend_time: Num
)
¶Anim
Play the animation asset
anim_lx
on theAnim
attached toentity
with a blend fade time. Plays from the beginning. Blend time is handled by some tracks, not all. Returns the newly startedAnim
instance.//fade in the animation over 0.6 seconds var anim = Anim.blend(entity, "player/idle", 0.6)
Entity
, anim_lx: ID
, time_offset: Num
)
¶Anim
Play the animation asset
anim_lx
on theAnim
attached toentity
, stopping all other active anims, and only playing this one. Thetime_offset
is a time in seconds to begin playback from. Returns the newly startedAnim
instance.var anim = Anim.play_only(entity, "player/idle", 0.5)
Entity
, anim_lx: ID
)
¶Anim
Play the animation asset
anim_lx
on theAnim
attached toentity
, stopping all other active anims, and only playing this one. Returns the newly startedAnim
instance.var anim = Anim.play_only(entity, "player/idle")
Entity
, anim: Anim
, reset: Bool
)
¶None
Stop the
Anim
instance if playing on theAnim
attached toentity
.If
reset
istrue
, the state of anything that was being animated by thisAnim
instance, will be reset to what it was before it was played. For example, if your animation is changing the transform position, it will revert back to the position at the time the animation was played.var anim = Anim.play(entity, "player/idle") Anim.stop(entity, anim, true)
Entity
, anim: Anim
)
¶None
Stop the
Anim
instance if playing on theAnim
attached toentity
. State is not reset (seeAnim.stop(entity, anim, reset)
).var anim = Anim.play(entity, "player/idle") Anim.stop(entity, anim)
Entity
, reset: Bool
)
¶None
Stop all active
Anim
instances playing on theAnim
attached toentity
. Ifreset
istrue
, state will be reset to the state before the animation started (seeAnim.stop(entity, anim, reset)
).var anim = Anim.play(entity, "player/idle") Anim.stop_all(entity, true)
Entity
)
¶None
Stop all active
Anim
instances playing on theAnim
attached toentity
. State is not reset (seeAnim.stop(entity, anim, reset)
).var anim = Anim.play(entity, "player/idle") Anim.stop_all(entity)
Entity
, anim: Anim
, track_id: Any
, track_type: Any
)
¶unknown
no docs found
Entity
, anim: Anim
, track_id: Any
)
¶unknown
no docs found
Entity
, anim: Anim
, track_id: Any
, min: Any
, max: Any
)
¶unknown
no docs found
Entity
, anim: Anim
, track_id: Any
)
¶unknown
no docs found
Entity
, anim: Anim
, track_id: Any
, property: Any
, value: Any
)
¶unknown
no docs found
Entity
, anim: Anim
, track_id: Any
, channel_id: Any
, channel_idx: Any
, interp: Any
, keys: Any
)
¶unknown
no docs found
Entity
, anim: Anim
, play_count: Num
)
¶None
Set the amount of times to play the
Anim
instance on theAnim
attached toentity
. Theplay_count
value can be0
, which will loop forever.//play 3 times and then end var anim = Anim.play(entity, "player/idle") Anim.set_play_count(entity, anim, 3)
Entity
, anim: Anim
, rate: Num
)
¶None
Set the playback rate of the
Anim
instance on theAnim
attached toentity
. The rate of1
is the default speed.0.5
is half speed, and2
is twice as fast.var anim = Anim.play(entity, "player/idle") Anim.set_rate(entity, anim, 0.5)
Entity
, anim: Anim
, start: Num
)
¶None
Set the start marker of the
Anim
instance on theAnim
attached toentity
. note This API is WIP.Anim.set_start(entity, anim, 0)
Entity
, anim: Anim
, end: Num
)
¶None
Set the end marker of the
Anim
instance on theAnim
attached toentity
. note This API is WIP.Anim.set_end(entity, anim, 1)
Entity
, anim: Anim
, time: Num
)
¶None
Set the current playback time of the
Anim
instance on theAnim
attached toentity
. note This API is WIP.Anim.set_interval_time(entity, anim, 0.5)
Entity
, anim: Anim
)
¶Num
Return the play count of the
Anim
instance on theAnim
attached toentity
.var play_count = Anim.get_play_count(entity, anim)
Entity
, anim: Anim
)
¶Num
Return the rate of playback of the
Anim
instance on theAnim
attached toentity
.var play_count = Anim.get_play_count(entity, anim)
Entity
, anim: Anim
)
¶Num
Return the duration of the
Anim
instance on theAnim
attached toentity
.var play_count = Anim.get_play_count(entity, anim)
Entity
, anim: Anim
)
¶Num
Return the start marker of the
Anim
instance on theAnim
attached toentity
.var play_count = Anim.get_play_count(entity, anim)
Entity
, anim: Anim
)
¶Num
Return the end marker of the
Anim
instance on theAnim
attached toentity
.var play_count = Anim.get_play_count(entity, anim)
Entity
, anim: Anim
)
¶Num
Return the current playback time of the
Anim
instance on theAnim
attached to entity. note This API is WIP.var play_count = Anim.get_play_count(entity, anim)
Entity
, anim: Anim
, fn: Fn
)
¶None
no docs found
AnimEvent¶
import "luxe: system/anim.modifier" for AnimEvent
no docs found
unknown
An event fired when an animation started playing.
unknown
An event fired when an animation is updated, but only if the track is set to emit the event.
unknown
An event fired when an animation is stopped or done playing.
AnimInterpolation¶
import "luxe: system/anim.modifier" for AnimInterpolation
An enum for types of interpolation in animation tracks.
unknown
An invalid or unknown value.
if(value == AnimInterpolation.unknown) { Log.print("unknown interpolation type!") }
unknown
The animation values between keys will be interpolated according to the curve defined by the keys themselves.
if(value == AnimInterpolation.curve) { Log.print("curve") }
unknown
The animation values between keys will be interpolated linearly. For example if your keys were
{ time=0 value=0 }
and{ time=1 value=4 }
, at the time of0.5
the value would be2
, half of the next key.if(value == AnimInterpolation.linear) { Log.print("linear") }
unknown
The animation values between keys would not be interpolated, they would jump from one value to the next. For example if your keys were
{ time=0 value=0 }
and{ time=1 value=3 }
, with discrete the value at time0.5
is still0
(instead of1.5
with linear). It will only change to3
when the next key is reached.if(value == AnimInterpolation.discrete) { Log.print("discrete") }
AnimInterpolation
)
¶String
Convert an
AnimInterpolation
value to a string.var type = AnimInterpolation.linear var name = AnimInterpolation.name(type) Log.print("type is %(name)") //expect: "linear"
String
)
¶AnimInterpolation
Get the
AnimInterpolation
value to a name.var type = AnimInterpolation.from_string("discrete") Log.print("discrete is value %(type)") //expect: "3", the internal value
AnimInterval¶
import "luxe: system/anim.modifier" for AnimInterval
no docs found
- create(world:
Any
, duration:Any
, rate:Any
) - create(world:
Any
, duration:Any
) - time(world:
Any
, anim:Any
) - set_time(world:
Any
, anim:Any
, time:Any
) - set_now(world:
Any
, anim:Any
, offset:Any
) - set_now(world:
Any
, anim:Any
) - set_play_count(world:
Any
, anim:Any
, count:Any
) - set_clock(world:
Any
, anim:Any
, clock:Any
) - set_rate(world:
Any
, anim:Any
, rate:Any
) - set_duration(world:
Any
, anim:Any
, duration:Any
) - set_start(world:
Any
, anim:Any
, start:Any
) - set_end(world:
Any
, anim:Any
, end:Any
) - get_now(world:
Any
, anim:Any
) - get_play_count(world:
Any
, anim:Any
) - get_clock(world:
Any
, anim:Any
) - get_rate(world:
Any
, anim:Any
) - get_duration(world:
Any
, anim:Any
) - get_start(world:
Any
, anim:Any
) - get_end(world:
Any
, anim:Any
)
Any
, duration: Any
, rate: Any
)
¶unknown
no docs found
Any
, duration: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
, time: Any
)
¶unknown
no docs found
Any
, anim: Any
, offset: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
, count: Any
)
¶unknown
no docs found
Any
, anim: Any
, clock: Any
)
¶unknown
no docs found
Any
, anim: Any
, rate: Any
)
¶unknown
no docs found
Any
, anim: Any
, duration: Any
)
¶unknown
no docs found
Any
, anim: Any
, start: Any
)
¶unknown
no docs found
Any
, anim: Any
, end: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
Any
, anim: Any
)
¶unknown
no docs found
AnimState¶
import "luxe: system/anim.modifier" for AnimState
An enum for the state of an
Anim
instance.
Num
The animation is inactive. :todo: This may be obsolete.
var state = Anim.get_state(entity, anim) if(state == AnimState.inactive) { Log.print("anim is inactive") }
Num
The animation is active and is playing.
var state = Anim.get_state(entity, anim) if(state == AnimState.playing) { Log.print("anim is playing") }
Num
The animation is ending, and will be marked complete next update.
var state = Anim.get_state(entity, anim) if(state == AnimState.ending) { Log.print("anim is ending") }
Num
The animation has ended and is complete.
var state = Anim.get_state(entity, anim) if(state == AnimState.complete) { Log.print("anim is complete") }
Num
)
¶String
Convert an
AnimState
value to a string.var type = AnimState.ending var name = AnimState.name(type) Log.print("type is %(name)") //expect: "ending"
String
)
¶Num
Convert a string to an enum value.
var state = AnimState.from_string("ending") var same = state == AnimState.ending //true
Data¶
import "luxe: system/anim.modifier" for Data
no docs found
var play : List = []
System¶
import "luxe: system/anim.modifier" for System
no docs found
- new(world:
World
)
World
)
¶System
no docs found