Skip to content

Cutscene Class

RileyWhitty edited this page Oct 17, 2023 · 8 revisions

Cutscene Class

The cutscene class is used to generate a cutscene with a image, dialogue and a continue button. This can be used at any point throughout the game although it is intended to be mainly used by the story system of the game.

The Cutscene class constructor takes two inputs.

dialogue

Is of type String. It represents the dialogue to be used to populate the cutscene. The dialogue text has automatic wrapping so line breaks aren't needed in the dialogue String but can still be added if you want to enforce vertical spacing between certain parts of the dialogue. Since the dialogue is spawned in using a Typing Label, extra formatting and animations can be applied to the text by adding tokens to the dialogue String. Examples on how to do this can be found here.

cutsceneType

Is of type CutsceneType which is a enum defined in the Cutscene class. It has two possible values, ALIEN and RADIO, and determines what image is displayed next to the cutscene dialogue text. When ALIEN is given, it will spawn the alien quest giver sprite and when RADIO is given it will spawn the radio sprite.

Spawning a Cutscene

To instantiate a cutscene object, simply define a Cutscene variable like below.

Cutscene cutscene = new Cutscene("I've had word from a settlement that needs help. They're still hoping there are Minutemen out there somewhere.", Cutscene.CutsceneType.ALIEN);

To actually spawn the cutscene (get it to display), you need to call the spawnCutscene method on the Cutscene object as shown below.

cutscene.spawnCutscene();

Doing so will generate a cutscene like the below.

image

Adding a new Cutscene Type

To add a new type of cutscene (this will only change the Picture and window text), you first have to add a new value to the CutsceneType enum in the Cutscene class. Then you will have to create an image to be used in the CutsceneDisplay (The image cannot be too wide, try to give it a ratio of width:height of 1:2 at a minimum) and an atlas file for it too. Then in the spawnSprite method in the CutsceneDisplay class you will have to add an additional else if statement inside of the main if statement (feel free to convert to a switch statement if more cutscene types are added). Then add the following code to the bottom of the if statement modifying it to include your new cutscene type enum and atlas file.

} else if (this.cutsceneType == Cutscene.CutsceneType.[YOUR CUTSCENE ENUM GOES HERE]) {

        npcAtlas = ServiceLocator.getResourceService().getAsset("images/[YOUR ATLAS FILE GOES HERE]", TextureAtlas.class);

        region = npcAtlas.findRegion(DEFAULT);

}

Additionally, to change the name that is displayed at the top of the dialogue window, you will have to modify the spawnCutsceneDisplay method by adding an additional else if statement in the main if statement using the below code modifying it to include the values you want.

else if (this.cutsceneType == Cutscene.CutsceneType.[YOUR CUTSCENE ENUM GOES HERE]) {

        dialogueWindow = new Window("[THE BNAME YOU WANT TO BE DISPLAYED GOES HERE]", skin);

}

Cutscene UML Diagram

image

Clone this wiki locally