Class AnimLayer
java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.armature.AnimLayer
One track of animation on an
Animator: it plays one clip at a time, blending smoothly from the last, over
the joints in its mask. Layers are stacked in the order they were made, later ones on top.
A layer can be driven: a function asked every frame which motion should play, which the layer follows,
blending whenever the answer changes. play(Motion) plays something regardless; once it ends (a
LoopMode.ONCE clip, a repeat count, or stop()) the driver takes over again.
animator.layer("base").drive(ctx -> ctx.moving() ? WALK : IDLE);
animator.layer("arms", l -> l.mask(JointMask.of("arm_left", "arm_right")));
animator.layer("breath", l -> l.blend(LayerBlend.ADDITIVE).weight(0.6F)).play(Motion.loop("breathe"));
animator.layer("arms").play(Motion.once("wave"));
-
Method Summary
Modifier and TypeMethodDescriptionblend(LayerBlend blend) @Nullable Stringclip()The clip playing, or null.drive(Function<ArmatureContext, @Nullable Motion> driver) Has the layer follow a function, asked every frame: whatever motion it returns plays, blending in when the answer changes; null blends back to rest (or to the layers below).fadeWeight(float weight, float seconds) Moves its weight to a new value over some seconds: fade a layer in or out as a whole.booleanWhether a clip is playing and has not ended (a held last frame counts as ended).booleanname()Plays a clip the way its file says to.Plays a motion now, setting the driver aside until it ends.floatprogress()How far through the clip playing, 0 to 1.speed(float speed) Plays everything on this layer faster or slower, on top of each motion's own speed.stop()Blends out whatplay(Motion)started, back to the driver or to rest, the way it blended in.stop(float fadeSeconds) floattime()Seconds into the clip playing.transition(String from, String to, Transition transition) How one clip blends into another on this layer:transition("run", "idle", Transition.freeze(0.4F)).transition(Transition transition) How animations on this layer blend into each other unless a rule or the motion says otherwise.transitions(boolean enabled) Turns blending on this layer on or off: off, every change cuts straight to the next animation, whatever the motions and rules say.transitions(TransitionRule rule) Picks transitions with code, before the pair rules and the default; return null to fall through to them.booleantransitionTo(Motion motion) The transition the next change to this motion would use, by the rules above.floatweight()weight(float weight) How strongly it shows, 0 to 1, at once.
-
Method Details
-
name
-
blend
-
mask
-
weight
How strongly it shows, 0 to 1, at once. -
fadeWeight
Moves its weight to a new value over some seconds: fade a layer in or out as a whole. -
weight
public float weight() -
speed
Plays everything on this layer faster or slower, on top of each motion's own speed. -
drive
Has the layer follow a function, asked every frame: whatever motion it returns plays, blending in when the answer changes; null blends back to rest (or to the layers below). Asking for the motion that is already playing changes nothing, so return constants, not new motions each time. -
transition
How animations on this layer blend into each other unless a rule or the motion says otherwise. Without one, the animator's default is used (Animator.transition), and without thatTransition.DEFAULT. -
transition
How one clip blends into another on this layer:transition("run", "idle", Transition.freeze(0.4F)). Either name may be"*"for any clip;fromis"*"too when nothing was playing. The most exact rule wins (both names, thenfrom, thento), then the last one given. -
transitions
Picks transitions with code, before the pair rules and the default; return null to fall through to them. -
transitions
Turns blending on this layer on or off: off, every change cuts straight to the next animation, whatever the motions and rules say. On by default. -
transitionsEnabled
public boolean transitionsEnabled() -
transitionTo
The transition the next change to this motion would use, by the rules above. -
play
-
play
-
stop
Blends out whatplay(Motion)started, back to the driver or to rest, the way it blended in. -
stop
-
isPlaying
public boolean isPlaying()Whether a clip is playing and has not ended (a held last frame counts as ended). -
isPlaying
-
clip
The clip playing, or null. -
time
public float time()Seconds into the clip playing. -
progress
public float progress()How far through the clip playing, 0 to 1.
-