Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create function for Cutscene
class CutsceneState extends FlxState {
//Additional code from before here
public static inline var TEXT_WIDTH:Int = 400
override public function create() {
createSkip();
createSceneText();
transitionText();
super.create();
}
public function createSkip() {
var margin = 48;
var barWidth = 100;
var x = FlxG.width - (barWidth + margin);
var y = margin;
var textSize = 12;
skipBar = new FlxBar(x, y, LEFT_TO_RIGHT, barWidth, 20, this,
"skipPerc", 0, 100, true); //Create the skip Bar
skipBar.createFilledBar(FlxColor.BLACK, FlxColor.RED, true,
FlxColor.WHITE); //Create the aesthetic of the bar
skipText = new FlxText(skipBar.x + (skipBar.width / 2), (skipBar.y),
50, 'Skip', textSize); //Setting up the text
skipText.y += 2;
skipText.x -= 12;
skipText.color = FlxColor.WHITE;
//Making the bar and text invisible until we start processing a skip
skipBar.visible = false;
skipText.visible = false;
//Most important adding them to the scene
add(skipBar);
add(skipText);
}
//Creates the large text we see on the scene
public function createSceneText() {
var textSize = 16;
sceneText = new FlxTypeText(0, 0, TEXT_WIDTH, '', textSize);
sceneText.screenCenter();
add(sceneText);
}
//Moves the text forward and displays it on screen. We started our index at -1, so this moves it to the first
//text.
public function transitionText() {
textIndex++;
//Grabs the text from the list and resets the text. Starts displaying the text and resets the delay.
var currentText = textList[textIndex % textList.length];
sceneText.resetText(currentText.text);
sceneText.start(0.05);
textDelay = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment