Class Cutscene
java.lang.Object
net.ixdarklord.coolcatcanvas.api.cutscene.Cutscene
A cutscene: a camera flown along keyframes while the player watches, with letterbox bars, fades, subtitles and
markers in time with it. It is plain data, the same on both sides: built in code, read from
assets/<namespace>/cutscene/<path>.json, made in the in-game editor, or sent by the server.
Cutscene intro = Cutscene.builder()
.keyframe(0, new Vec3(10, 80, 10), 135, 20)
.keyframe(100, new Vec3(-4, 72, 30), 200, 5).easing(Easing.SINE_IN_OUT).fov(45)
.keyframe(160, new Vec3(-6, 70, 42), 180, 0)
.letterbox()
.fadeIn(15).fadeOut(15)
.subtitle(20, 70, Component.literal("Long ago..."))
.marker(100, MyMod.id("thunder"))
.build();
Times are ticks from the start; fractions are allowed. On the client, Cutscenes registers and plays them;
on the server, CutsceneControl plays them for a player.
The camera only shows what the client has loaded: chunks around the player, not around the camera. Keep a path within the player's view distance of where they stand.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds aCutscene.static final recordA named moment: when the cutscene passes it, the client firesCutsceneEvents.MARKERwith its id, for a sound, an effect, a camera shake, anything that should land on a beat.static final recordA line of text shown at the foot of the screen for a while. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatThe widescreen cinema ratio the letterbox bars frame by default.static final com.mojang.serialization.Codec<Cutscene> -
Method Summary
Modifier and TypeMethodDescriptionanchor()floatbarsAt(float time) How far the letterbox bars are in at a time, 0 to 1.floatblendIn()Over how many ticks the view glides from the player's own into the first keyframe; 0 cuts.floatblendOut()Over how many ticks the view glides back to the player's own at the end; 0 cuts.static Cutscene.Builderbuilder()floatduration()How long it lasts, in ticks.booleaneditable()Whether the in-game editor may open it.fade()How dark the screen is over time, 0 to 1; empty for no fades.floatfadeAt(float time) How dark the fade is at a time, 0 to 1.intThe colour faded to, as0xRRGGBB.focuses()booleanhideHud()booleanWhether it can be written to a file or sent to a client: every easing it uses has a name inEasings.The keyframes, in time order.floatThe aspect ratio (width over height) the letterbox bars frame, or 0 for no bars.booleanWhether the player can't move, look or act while it plays.markers()The markers, in time order.poseAt(float time) The camera at a time, in the cutscene's own space, taking 70 for a keyframe without a field of view.poseAt(float time, float playerFov) The camera at a time, in the cutscene's own space, before anyCameraFocusturns it.booleanA builder holding everything this cutscene has, to make a changed copy.
-
Field Details
-
CINEMATIC_ASPECT
public static final float CINEMATIC_ASPECTThe widescreen cinema ratio the letterbox bars frame by default.- See Also:
-
CODEC
-
-
Method Details
-
builder
-
toBuilder
A builder holding everything this cutscene has, to make a changed copy. -
keyframes
The keyframes, in time order. -
duration
public float duration()How long it lasts, in ticks. -
anchor
-
letterbox
public float letterbox()The aspect ratio (width over height) the letterbox bars frame, or 0 for no bars. -
fade
How dark the screen is over time, 0 to 1; empty for no fades. -
fadeColor
public int fadeColor()The colour faded to, as0xRRGGBB. -
focuses
-
subtitles
-
markers
The markers, in time order. -
blendIn
public float blendIn()Over how many ticks the view glides from the player's own into the first keyframe; 0 cuts. -
blendOut
public float blendOut()Over how many ticks the view glides back to the player's own at the end; 0 cuts. -
hideHud
public boolean hideHud() -
lockInput
public boolean lockInput()Whether the player can't move, look or act while it plays. -
skippable
public boolean skippable() -
editable
public boolean editable()Whether the in-game editor may open it. A cutscene that isn't editable is left out of the editor's list, so players can't load a copy of it to change or reuse. It plays the same either way. -
isPortable
public boolean isPortable()Whether it can be written to a file or sent to a client: every easing it uses has a name inEasings. Cutscenes built with lambdas orreversed()curves only play where they were built. -
barsAt
public float barsAt(float time) How far the letterbox bars are in at a time, 0 to 1. Without a track of its own, a letterboxed cutscene slides its bars in over its first ticks and out over its last. -
fadeAt
public float fadeAt(float time) How dark the fade is at a time, 0 to 1. -
poseAt
The camera at a time, in the cutscene's own space, taking 70 for a keyframe without a field of view. -
poseAt
The camera at a time, in the cutscene's own space, before anyCameraFocusturns it.- Parameters:
playerFov- the field of view keyframes without one of their own take
-