From e78eb6b704be4f3e671d2a2f5bebb34c043584aa Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 3 Jan 2022 15:29:25 -0700 Subject: [PATCH] fix drawOnSprite for scaled sprite --- .../src/hollywoo_flixel/SpriteTools.kiss | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/SpriteTools.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/SpriteTools.kiss index f0f8b5d9..9f4e3bc5 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/SpriteTools.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/SpriteTools.kiss @@ -4,11 +4,11 @@ (unless pos.anchorY (set pos.anchorY (Percent 0.5))) (let [&mut x (coordIn pos.x (/ canvas.width canvas.scale.x) pos.offsetX) &mut y (coordIn pos.y (/ canvas.height canvas.scale.y) pos.offsetY)] - (-= x (coordIn pos.anchorX (/ stamp.width stamp.scale.x))) - (-= y (coordIn pos.anchorY (/ stamp.height stamp.scale.y))) + (-= x (coordIn pos.anchorX stamp.width)) + (-= y (coordIn pos.anchorY stamp.height)) [x y])) -(function :Int coordIn [:RelativeCoordinate coord :Int range &opt :Int offset] +(function :Int coordIn [:RelativeCoordinate coord :Float range &opt :Int offset] (+ (or offset 0) (Math.round (case coord @@ -32,9 +32,13 @@ (stamp.updateHitbox))) (function :Void drawOnSprite [:FlxSprite stamp :FlxSprite canvas :RelativePosition pos] + (scaleStampOn stamp canvas pos) (let [[x y] (positionOn stamp canvas pos)] - (scaleStampOn stamp canvas pos) - (canvas.stamp stamp x y))) + (let [oX stamp.origin.x + oY stamp.origin.y] + (stamp.origin.set 0 0) + (canvas.stamp stamp x y) + (stamp.origin.set oX oY)))) // TODO allow specifying size relative to canvas (function :Void writeOnSprite [:String text :Int size :FlxSprite canvas :RelativePosition pos &opt :FlxColor color]