From a393db0eda19424f2d27ac0f49c505f3fcc4c89c Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 2 Nov 2021 20:02:20 -0400 Subject: [PATCH] make SceneFlxStates SubStates --- .../src/hollywoo_flixel/FlxDirector.kiss | 13 ++++++++----- .../src/hollywoo_flixel/MovieFlxState.kiss | 1 + .../src/hollywoo_flixel/SceneFlxState.hx | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index 315ba80c..36102f39 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -13,9 +13,12 @@ (prop &mut :SceneFlxState currentState) (method :Void showScene [:Scene scene :Appearance appearance :Continuation cc] + // Close the last scene state + (when currentState + (currentState.close)) // TODO on the first appearance, give a super (for some scenes but probably not others... hm....) (set currentState (cast scene SceneFlxState)) - (FlxG.switchState currentState) + (FlxG.state.openSubState currentState) (cc)) (var STAGE_LEFT_X 150) @@ -70,14 +73,14 @@ // Make a dialog box (unless dialogBox (set dialogBox (new FlxSprite DIALOG_X DIALOG_Y)) - (dialogBox.makeGraphic DIALOG_WIDTH DIALOG_HEIGHT DIALOG_BOX_COLOR) - (currentState.add dialogBox)) + (dialogBox.makeGraphic DIALOG_WIDTH DIALOG_HEIGHT DIALOG_BOX_COLOR)) + (currentState.add dialogBox) (dialogBox.revive) // show the dialog (unless dialogText // TODO use FlxTypeText to reveal dialog gradually - (set dialogText (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE)) - (currentState.add dialogText)) + (set dialogText (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE))) + (currentState.add dialogText) (set dialogText.text text) // show the speaker name (unless speakerNameText diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/MovieFlxState.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/MovieFlxState.kiss index 6bf108fc..6df745b2 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/MovieFlxState.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/MovieFlxState.kiss @@ -2,6 +2,7 @@ (prop &mut :FlxMovie movie) (method &override :Void create [] + (set destroySubStates false) (super.create) (set director (new FlxDirector)) (set movie (new FlxMovie director))) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.hx b/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.hx index a3b7042d..df5864c1 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.hx +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.hx @@ -2,11 +2,11 @@ package hollywoo_flixel; import kiss.Prelude; import kiss.List; -import flixel.FlxState; +import flixel.FlxSubState; import flixel.FlxSprite; import flixel.FlxG; import hollywoo.Scene; import hollywoo_flixel.FlxMovie; @:build(kiss.Kiss.build()) -class SceneFlxState extends FlxState {} +class SceneFlxState extends FlxSubState {}