Class Motion
java.lang.Object
net.ixdarklord.coolcatcanvas.api.armature.Motion
How to play one clip: how it loops, how fast, and how it blends in from whatever was playing. Motions are immutable
values, so keep them in constants; each method returns a changed copy. Both sides know them, so the server can send
one with
ArmatureControl.
static final Motion WALK = Motion.loop("walk"); // the layer's transition rules
static final Motion RUN = Motion.loop("run").transition(Transition.crossfade(0.3F));
static final Motion ATTACK = Motion.once("attack").speed(1.5F).then(Motion.loop("idle"));
static final Motion SPIN = Motion.loop("spin").repeat(3).fade(0.1F).ease(Easing.BACK_OUT);
A motion that names no transition (transition, fade(float), ease(Easing)) blends in the way its layer's
rules say, so how animations meet can be set in one place.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatstatic final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, Motion> -
Method Summary
Modifier and TypeMethodDescriptionclip()The curve of the blend in.easing()booleanfade(float seconds) Seconds to blend in from what was playing (a crossfade unlesstransitionsays otherwise).floatfadeIn()Seconds it blends in over, as asked; the default if it leaves that to its layer.floatfadeOut()fadeOut(float seconds) Seconds to blend back to rest when aLoopMode.ONCEclip ends with nothing after it (else its blend-in time).floatSeconds to blend back to rest at its end, if asked; negative when not (its blend-in time is used).inthashCode()static Motion@Nullable LoopModeloop()The loop mode asked for; null means the clip's own.static Motion@Nullable Motionnext()static MotionA clip, looping the way its file says (Blockbench's loop setting, or Bedrock'sloop).static Motionstatic Motionintrepeat()repeat(int times) Loops this many times, then ends asLoopMode.ONCEwould; 0 loops forever.restart()Plays from the start even if this clip is already playing on the layer.booleanrestarts()booleanWhether the two would play the same thing, so switching from one to the other needs no new blend.floatspeed()speed(float speed) Plays faster (2) or slower (0.5); negative plays backwards.floatstartAt()startAt(float seconds) Starts this many seconds into the clip.What plays when this ends (aLoopMode.ONCEclip, or a loop with a repeat count).toString()@Nullable TransitionThe transition asked for; null leaves it to the layer.transition(@Nullable Transition transition) How it blends in from what was playing, whatever its layer's rules say; null leaves it to them.
-
Field Details
-
DEFAULT_FADE
public static final float DEFAULT_FADE -
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, Motion> STREAM_CODEC
-
-
Method Details
-
of
-
loop
-
once
-
hold
-
pingPong
-
loopMode
-
repeat
Loops this many times, then ends asLoopMode.ONCEwould; 0 loops forever. Makes it aLoopMode.LOOP. -
speed
Plays faster (2) or slower (0.5); negative plays backwards. -
transition
How it blends in from what was playing, whatever its layer's rules say; null leaves it to them. -
fade
Seconds to blend in from what was playing (a crossfade unlesstransitionsays otherwise). 0 cuts. -
ease
-
fadeOut
Seconds to blend back to rest when aLoopMode.ONCEclip ends with nothing after it (else its blend-in time). -
startAt
Starts this many seconds into the clip. -
restart
Plays from the start even if this clip is already playing on the layer. Without it, asking for the clip that is playing changes nothing, which is what a driver asked every frame needs. -
then
What plays when this ends (aLoopMode.ONCEclip, or a loop with a repeat count). Chains can be long. -
clip
-
loop
The loop mode asked for; null means the clip's own. -
repeat
public int repeat() -
speed
public float speed() -
transition
The transition asked for; null leaves it to the layer. -
fadeIn
public float fadeIn()Seconds it blends in over, as asked; the default if it leaves that to its layer. -
fadeOutAsked
public float fadeOutAsked()Seconds to blend back to rest at its end, if asked; negative when not (its blend-in time is used). -
fadeOut
public float fadeOut() -
easing
-
startAt
public float startAt() -
restarts
public boolean restarts() -
next
-
sameAs
Whether the two would play the same thing, so switching from one to the other needs no new blend. -
equals
-
hashCode
-
toString
-