preserve overlay status of props in scenes

This commit is contained in:
2023-06-14 08:08:15 -06:00
parent d4d932299c
commit 10071be9c0
2 changed files with 13 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ class FlxMovie extends Movie<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSpr
public var propScales:JsonMap<HFloat>;
public var propsInScene:Map<String,Array<String>> = [];
public var overlaidPropsInScenes:Map<String,Map<FlxSprite,String>> = [];
public var tweenedPositionsOfSpritesInScenes:Map<String,Map<FlxSprite,FlxPoint>> = [];
public var tweens:Array<FlxTween> = [];

View File

@@ -21,6 +21,9 @@
(method &override :Void _showScene [:Scene<FlxSprite,ActorFlxSprite,FlxSprite,FlxCamera> scene :Appearance appearance :FlxCamera camera :Continuation cc]
(super._showScene scene appearance camera
(makeCC
(whenLet [overlaidProps (dictGet overlaidPropsInScenes sceneKey)]
(doFor =>sprite key overlaidProps
(overlayPropOnCurrentSet key (makeCC null))))
(whenLet [tweenedPositions (dictGet tweenedPositionsOfSpritesInScenes sceneKey)]
(doFor =>sprite point tweenedPositions
(set sprite.x point.x)
@@ -32,6 +35,12 @@
(tweenedPositions.remove (dictGet actors actorName)))
(super.moveCharacter actorName newPosition newFacing cc))
(method &override removeProp [name :Continuation cc]
(let [prop (dictGet props name)]
(whenLet [overlaidProps (dictGet overlaidPropsInScenes sceneKey)]
(overlaidProps.remove prop)))
(super.removeProp name cc))
(method linearMotion [:FlxSprite sprite :Float destX :Float destY :Float speed &opt :Void->Void cc :String soundLoop :Float volumeMod :Array<FlxSprite> connectedSprites]
(unless (tweenedPositionsOfSpritesInScenes.exists sceneKey)
(dictSet tweenedPositionsOfSpritesInScenes sceneKey (new Map)))
@@ -229,6 +238,9 @@
(let [propKey (kiss.FuzzyMapTools.bestMatch props propKey)]
(dictSet shownProps propKey true) // Don't scale when showing
(withProp propKey p
(unless (overlaidPropsInScenes.exists sceneKey)
(dictSet overlaidPropsInScenes sceneKey (new Map)))
(dictSet (dictGet overlaidPropsInScenes sceneKey) p propKey)
(withSceneSetCC sceneKey bg
(addProp propKey (new StagePosition bg.x bg.y 1) cc)
(p.setGraphicSize (Std.int bg.width) (Std.int bg.height))