From 7d88fd4de37cf52364cd206395a43d8e7f991514 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 3 Jan 2022 16:46:13 -0700 Subject: [PATCH] stage positions behind the others --- .../src/hollywoo_flixel/FlxDirector.kiss | 25 ++++++++++++++++++- .../src/hollywoo_flixel/FlxMovie.hx | 2 ++ .../src/hollywoo_flixel/SceneFlxState.kiss | 4 +++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index b8ea3617..6dc926c1 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -27,6 +27,7 @@ (var STAGE_LEFT_X 150) (var STAGE_RIGHT_X (- 1280 150)) +(var STAGE_BEHIND_DY -250) (var ACTOR_Y 500) (var ACTOR_WIDTH 300) @@ -39,8 +40,14 @@ (set character.actor.x (- (case character.stagePosition (Left + (set currentState.actorOnLeft character.actor) + STAGE_LEFT_X) + (LeftBehind STAGE_LEFT_X) (Right + (set currentState.actorOnRight character.actor) + STAGE_RIGHT_X) + (RightBehind STAGE_RIGHT_X) (otherwise (throw "unsupported stage position"))) (/ character.actor.width 2))) @@ -48,10 +55,26 @@ (let [bottom (+ character.actor.y character.actor.height)] (when (> bottom 720) (-= character.actor.y (- bottom 720)))) - (currentState.add character.actor) + (let [&mut reAddFront false] + (case character.stagePosition + ((or LeftBehind RightBehind) + (set reAddFront true) + (+= character.actor.y STAGE_BEHIND_DY)) + (otherwise)) + (when reAddFront + (when currentState.actorOnLeft (currentState.remove currentState.actorOnLeft)) + (when currentState.actorOnRight (currentState.remove currentState.actorOnRight)) + (currentState.add character.actor) + (when reAddFront + (when currentState.actorOnLeft (currentState.add currentState.actorOnLeft)) + (when currentState.actorOnRight (currentState.add currentState.actorOnRight))))) (cc)) (method :Void hideCharacter [:Character character :Continuation cc] + (when (= currentState.actorOnLeft character.actor) + (set currentState.actorOnLeft null)) + (when (= currentState.actorOnRight character.actor) + (set currentState.actorOnRight null)) (currentState.remove character.actor) (cc)) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx index 1ad6841d..e4bed398 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxMovie.hx @@ -12,6 +12,8 @@ import openfl.Assets; enum FlxStagePosition { Left; Right; + LeftBehind; + RightBehind; } enum FlxStageFacing { diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.kiss index b5b35f95..b0b0026c 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/SceneFlxState.kiss @@ -1,3 +1,7 @@ +// Track which actors are in FRONT of the stage so actors can appear behind them +(prop &mut :ActorFlxSprite actorOnLeft null) +(prop &mut :ActorFlxSprite actorOnRight null) + (defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective] [ &mut :FlxState parent null