FlxLightSource

This commit is contained in:
2023-03-29 06:47:45 -06:00
parent 1b49540dde
commit 76c8e2283d
2 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
package hollywoo_flixel;
import kiss.Prelude;
import kiss.List;
import flixel.math.FlxPoint;
import flixel.util.FlxColor;
@:build(kiss.Kiss.build())
class FlxLightSource {}

View File

@@ -0,0 +1,12 @@
(defNew [&prop :Array<FlxPoint> points
&prop :FlxColor color])
(method stringify []
"${color}|$(.join (for p points "${p.x}|${p.y}") "|")")
(method parse [:String data]
(case (data.split "|")
([::colorStr ...coordStrs]
(let [points (groups coordStrs 2)]
(new FlxLightSource (for [x y] points (new FlxPoint (Std.parseFloat x) (Std.parseFloat y))) (Std.parseInt colorStr))))
(never otherwise)))