6. The intro and the outro
Goal: two cinematics made in the editor with no code. The intro sweeps over the homestead while Aldric and Brann talk (Esc skips it); the outro pulls back over the hold (it can't be skipped).
Make the intro in the Cinematic panel
- Open the homestead and the Cinematic panel (bottom bar). Click New.
- Camera lane: move the view and click Set from the view every few seconds (over the base, closer on the hall, a dissolve to the enemy camp, back). Pick a path (line, smooth, curve) and an ease per key.
- Screen lane: one clip the whole length with letterbox and vignette; a fade from black over the first two seconds.
- Dialog lane: a clip per line, with its speaker (
campaign.aldric,campaign.brann), words and duration. - Add markers (
home,camp,back) that the panel jumps to and code can wait for. - Scrub to preview, click Play to watch it in the game, then Save. It writes
src/campaign/cinematics/intro.json:
{
"id": "campaign.intro",
"length": 22,
"lanes": [
{
"id": "camera",
"kind": "camera",
"items": [
{ "at": 0, "value": { "x": 20, "z": 60, "distance": 44, "yaw": 0.4, "pitch": 0.95 } },
{ "at": 6, "value": { "x": 22, "z": 58, "distance": 22, "yaw": 0.9, "pitch": 0.7 }, "path": "smooth", "ease": "inOutCubic" },
{ "at": 12, "value": { "x": 58, "z": 22, "distance": 30, "yaw": 2.4, "pitch": 0.85 }, "transition": "dissolve" }
]
},
{
"id": "screen",
"kind": "screen",
"items": [
{ "at": 0, "for": 22, "letterbox": 2.39, "vignette": 0.3, "in": 0.6, "out": 0.8 },
{ "at": 0, "for": 2, "fade": 1, "in": 0, "out": 2 }
]
},
{
"id": "dialog",
"kind": "dialog",
"items": [
{ "at": 2, "for": 4, "speaker": "campaign.aldric", "text": "Home. Three years on the road, and the woods have gone dark while we were away." }
]
}
],
"markers": [
{ "at": 0, "name": "home", "kind": "section" },
{ "at": 12, "name": "camp", "kind": "section" }
]
}Make the outro the same way over the pass: the camera pulling back and up, two lines, a fade to black.
List them in the view
// src/campaign/view/index.ts
import introFile from '../cinematics/intro.json'
import outroFile from '../cinematics/outro.json'
export const campaignView: GameView<CampaignUnit, CampaignResource, CampaignMessage> = {
cinematics: {
defs: {
'campaign.intro': { def: readCinematic(introFile), back: true },
'campaign.outro': { def: readCinematic(outroFile), skippable: false },
[PARLEY]: { play: parley, back: true }
},
speakers: {
[ALDRIC]: { name: 'Aldric', color: '#8fb8ff' },
[BRANN]: { name: 'Sergeant Brann', color: '#d7c38a' },
[VARGA]: { name: 'Varga', color: '#ff7a5a' }
}
}
// …
}readCinematic checks the file. back: true returns the camera afterwards; skippable: false blocks Esc. Files and scripts (the parley) are listed and played the same way.
Play them from the rules
// src/campaign/missions/homecoming.ts
export const briefing = defineSequence({ id: 'campaign.briefing', steps: [
// the screen lets the first tick pass before it draws: the intro is the first thing seen, the game waiting
wait(0),
cinematic('campaign.intro', { hold: true, wait: 'ended' }),
wait(0.5),
...talk(PLAYER, [
{ speaker: BRANN, text: MSG.homeStart, seconds: 5 },
{ speaker: ALDRIC, text: MSG.homeCamp, seconds: 5 }
])
] })The screen reports how a cinematic ended as a player command, so the sequence resumes on the same tick everywhere. The outro is a held, unwaited step of mission three's end (chapter 5).
Between missions
A cinematic with no game around it is a scene: cinematicScene({ id, game, map, cinematic, then: { scene } }). See Add a scene.
Next: 7. The campaign menu.