Created
January 29, 2021 23:52
-
-
Save KinoAR/3d6bba861a58c26dccc348c5e4152abd to your computer and use it in GitHub Desktop.
Create function for Cutscene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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