From b7efec5844bf7708cd92a8408b7bb04b19a3ba97 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 25 May 2023 18:43:25 -0600 Subject: [PATCH] put character sprites in layers --- src/hollywoo_flixel/FlxDirector.kiss | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/hollywoo_flixel/FlxDirector.kiss b/src/hollywoo_flixel/FlxDirector.kiss index 77a4a4d..9d890cc 100644 --- a/src/hollywoo_flixel/FlxDirector.kiss +++ b/src/hollywoo_flixel/FlxDirector.kiss @@ -251,16 +251,24 @@ (/ character.actor.width 2))) (set character.actor.y character.stagePosition.y) // Bump sprites up from the bottom if they're too tall - (let [bottom (+ character.actor.y character.actor.height)] - (when (> bottom FlxG.height) - (-= character.actor.y (- bottom FlxG.height)))) - // Display with y adjusted by z: - (-= character.actor.y character.stagePosition.z) - (FlxG.state.add character.actor) + (cond + ((flxMovie.presetPositions.exists (character.stagePosition.stringify)) + (let [bottom (+ character.actor.y character.actor.height)] + (when (> bottom FlxG.height) + (-= character.actor.y (- bottom FlxG.height)))) + // Display with y adjusted by z: + (-= character.actor.y character.stagePosition.z) + (let [layer (- LAYER_MAX (% character.stagePosition.z flxMovie.STAGE_BEHIND_DY))] + (.add (nth spriteLayers layer) character.actor))) + (true + (.add (nth spriteLayers (Std.int character.stagePosition.z)) character.actor))) + (cc)) (method :Void hideCharacter [:Character character :FlxCamera camera :Continuation cc] (FlxG.state.remove character.actor) + (doFor layer spriteLayers + (layer.remove character.actor)) (cc)) (prop &mut :Null nextCC)