scale props before calculating FullControl positions

This commit is contained in:
2023-06-22 13:22:43 -06:00
parent 45772dfbdb
commit 02ad3c92a7
3 changed files with 18 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
# @install: lix --silent download "gh://github.com/kiss-lang/kiss-flixel#7381447087453981c8fa71dc004063bdc77033a7" into kiss-flixel/0.0.0/github/7381447087453981c8fa71dc004063bdc77033a7 # @install: lix --silent download "gh://github.com/kiss-lang/kiss-flixel#70a1f880152be4bb03179dd79e9fe739d086ba7b" into kiss-flixel/0.0.0/github/70a1f880152be4bb03179dd79e9fe739d086ba7b
-lib flixel -lib flixel
-lib flixel-addons -lib flixel-addons
-lib flixel-ui -lib flixel-ui
@@ -6,5 +6,5 @@
-lib kiss-tools -lib kiss-tools
-lib lime -lib lime
-lib openfl -lib openfl
-cp ${HAXE_LIBCACHE}/kiss-flixel/0.0.0/github/7381447087453981c8fa71dc004063bdc77033a7/src/ -cp ${HAXE_LIBCACHE}/kiss-flixel/0.0.0/github/70a1f880152be4bb03179dd79e9fe739d086ba7b/src/
-D kiss-flixel=0.0.0 -D kiss-flixel=0.0.0

View File

@@ -586,6 +586,17 @@
(prop &mut :Bool autoPlaceProps true) (prop &mut :Bool autoPlaceProps true)
(method scaleProp [:FlxSprite prop]
(let [propKey (_propKey prop)
:Float scale .value (flxMovie.propScales.get propKey)]
(when (StringTools.contains propKey "anonProp") (return))
(unless (flxMovie.propsInScene.exists flxMovie.sceneKey)
(dictSet flxMovie.propsInScene flxMovie.sceneKey []))
(unless !(= -1 (.indexOf (dictGet flxMovie.propsInScene flxMovie.sceneKey) propKey))
(.push (dictGet flxMovie.propsInScene flxMovie.sceneKey) propKey))
(prop.scale.set scale scale)
(prop.updateHitbox)))
(method :Void showProp [:FlxSprite prop :StagePosition position :Appearance appearance :FlxCamera camera :Continuation cc] (method :Void showProp [:FlxSprite prop :StagePosition position :Appearance appearance :FlxCamera camera :Continuation cc]
(set prop.cameras [camera]) (set prop.cameras [camera])
(let [width (min (max prop.width PROP_MIN_WIDTH) PROP_MAX_WIDTH)] (let [width (min (max prop.width PROP_MIN_WIDTH) PROP_MAX_WIDTH)]
@@ -616,14 +627,7 @@
(-= prop.y (- propBottom FlxG.height))))) (-= prop.y (- propBottom FlxG.height)))))
// Otherwise, let the director scale props // Otherwise, let the director scale props
(true (true
(let [propKey (_propKey prop) (scaleProp prop)))
:Float scale .value (flxMovie.propScales.get propKey)]
(unless (flxMovie.propsInScene.exists flxMovie.sceneKey)
(dictSet flxMovie.propsInScene flxMovie.sceneKey []))
(unless !(= -1 (.indexOf (dictGet flxMovie.propsInScene flxMovie.sceneKey) propKey))
(.push (dictGet flxMovie.propsInScene flxMovie.sceneKey) propKey))
(prop.scale.set scale scale)
(prop.updateHitbox))))
(let [layerNum position.z] (let [layerNum position.z]
(assertEquals layerNum (Std.int layerNum)) (assertEquals layerNum (Std.int layerNum))

View File

@@ -137,9 +137,11 @@
(_canvas.makeGraphic FlxG.width FlxG.height FlxColor.BLACK)) (_canvas.makeGraphic FlxG.width FlxG.height FlxColor.BLACK))
_canvas) _canvas)
(method :StagePosition FullControl [:FlxSprite s :Int layer :RelativePosition rpos] (method :StagePosition FullControl [:FlxSprite s :Int layer :RelativePosition rpos &opt :Bool isProp]
(assert (<= 0 layer FlxDirector.LAYER_MAX) "Layer $layer is out of range 0-$FlxDirector.LAYER_MAX") (assert (<= 0 layer FlxDirector.LAYER_MAX) "Layer $layer is out of range 0-$FlxDirector.LAYER_MAX")
(let [[x y] (SpriteTools.positionOn s (canvas) rpos)] (when isProp
(flxDirector.scaleProp s))
(let [[x y] (SpriteTools.positionOn s (canvas) rpos true)]
(new StagePosition x y layer))) (new StagePosition x y layer)))
(method namePlates [:Array<String> names :Dynamic delayLength :Bool delayWhileShown :Void->Void cc] (method namePlates [:Array<String> names :Dynamic delayLength :Bool delayWhileShown :Void->Void cc]