fix null error in GroupTools

This commit is contained in:
2022-08-12 14:58:45 +00:00
parent 9321ecb9ec
commit 41140798b8

View File

@@ -18,21 +18,22 @@
(function :FlxRect calculateScreenBounds <>[:FlxSprite T] [:FlxTypedGroup<T> group &opt :FlxCamera camera :Float margin] (function :FlxRect calculateScreenBounds <>[:FlxSprite T] [:FlxTypedGroup<T> group &opt :FlxCamera camera :Float margin]
(unless margin (set margin 0)) (unless margin (set margin 0))
(let [s (group.getFirstAlive) (ifLet [s (group.getFirstAlive)]
r (new FlxRect) (let [r (new FlxRect)
bounds (s.getScreenBounds r camera) bounds (s.getScreenBounds r camera)
&mut minX bounds.left &mut minX bounds.left
&mut maxX bounds.right &mut maxX bounds.right
&mut minY bounds.top &mut minY bounds.top
&mut maxY bounds.bottom] &mut maxY bounds.bottom]
(group.forEach ->sprite (group.forEach ->sprite
(let [bounds (sprite.getScreenBounds r camera)] (let [bounds (sprite.getScreenBounds r camera)]
(setMin minX bounds.left) (setMin minX bounds.left)
(setMin minY bounds.top) (setMin minY bounds.top)
(setMax maxX bounds.right) (setMax maxX bounds.right)
(setMax maxY bounds.bottom))) (setMax maxY bounds.bottom)))
(r.fromTwoPoints (r.fromTwoPoints
(new FlxPoint (- minX margin) (- minY margin)) (new FlxPoint (- minX margin) (- minY margin))
(new FlxPoint (+ maxX margin) (+ maxY margin))))) (new FlxPoint (+ maxX margin) (+ maxY margin))))
(new FlxRect 0 0 0 0)))