From bcdb751fd861156b5acec2fe3b58aa171bd9f159 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 26 Sep 2024 14:02:26 -0500 Subject: [PATCH] rename and check flash --- .../source/{GuageState.hx => GaugeState.hx} | 78 +++++++++---------- Features/FlxPieDial/source/Main.hx | 5 ++ 2 files changed, 44 insertions(+), 39 deletions(-) rename Features/FlxPieDial/source/{GuageState.hx => GaugeState.hx} (61%) diff --git a/Features/FlxPieDial/source/GuageState.hx b/Features/FlxPieDial/source/GaugeState.hx similarity index 61% rename from Features/FlxPieDial/source/GuageState.hx rename to Features/FlxPieDial/source/GaugeState.hx index c9d70a3f1..dacbf81f1 100644 --- a/Features/FlxPieDial/source/GuageState.hx +++ b/Features/FlxPieDial/source/GaugeState.hx @@ -2,7 +2,7 @@ package; import flixel.FlxG; import flixel.FlxState; -import flixel.addons.display.FlxPieGuage; +import flixel.addons.display.FlxRadialGauge; import flixel.group.FlxGroup; import flixel.system.FlxAssets; import flixel.tweens.FlxTween; @@ -10,16 +10,16 @@ import flixel.util.FlxColor; import openfl.geom.Rectangle; /** - * Demo for the soon to be added feature, FlxPieGuage. Will replace FlxPieDial and this demo + * Demo for the soon to be added feature, FlxRadialGauge. Will replace FlxPieDial and this demo */ -class GuageState extends FlxState +class GaugeState extends FlxState { override public function create():Void { super.create(); FlxG.cameras.bgColor = FlxColor.GRAY; - final graphic = FlxG.bitmap.create(50, 50, FlxColor.BLACK, true, "make-guage"); + final graphic = FlxG.bitmap.create(50, 50, FlxColor.BLACK, true, "make-gauge"); graphic.bitmap.fillRect(new Rectangle(2, 2, 46, 46), FlxColor.WHITE); final colors = [FlxColor.RED, FlxColor.BLUE, FlxColor.LIME, FlxColor.WHITE, FlxColor.YELLOW, FlxColor.MAGENTA]; @@ -27,55 +27,55 @@ class GuageState extends FlxState final spacingY = 71; final setSize = colors.length; - inline function makeStaticShapeGuage(x, y, color:FlxColor, shape:FlxPieGuageShape, clockwise = true, innerRadius:Int, amount:Float) + inline function makeStaticShapeGauge(x, y, color:FlxColor, shape:FlxRadialGaugeShape, clockwise = true, innerRadius:Int, amount:Float) { - final guage = new FlxPieGuage(x, y); - guage.makePieDialGraphic(shape, 25, innerRadius, color); + final gauge = new FlxRadialGauge(x, y); + gauge.makePieDialGraphic(shape, 25, innerRadius, color); if (!clockwise) { - guage.setOrientation(270, -90); + gauge.setOrientation(270, -90); } - guage.amount = amount; - add(guage); - return guage; + gauge.amount = amount; + add(gauge); + return gauge; } - inline function makeStaticAssetGuage(x, y, graphic, clockwise = true, amount:Float, color = FlxColor.WHITE) + inline function makeStaticAssetGauge(x, y, graphic, clockwise = true, amount:Float, color = FlxColor.WHITE) { - final guage = new FlxPieGuage(x, y, graphic); - guage.color = color; + final gauge = new FlxRadialGauge(x, y, graphic); + gauge.color = color; if (!clockwise) { - guage.setOrientation(270, -90); + gauge.setOrientation(270, -90); } - guage.amount = amount; - add(guage); - return guage; + gauge.amount = amount; + add(gauge); + return gauge; } - inline function makeStaticSet(x:Float, y, graphic:GuageGraphic, clockwise = true) + inline function makeStaticSet(x:Float, y, graphic:GaugeGraphic, clockwise = true) { switch (graphic) { case SHAPE(shape, innerRadius): final innerRadius = innerRadius == null ? 0 : innerRadius; for (i in 0...setSize) - makeStaticShapeGuage(x + i * spacingX, y, colors[i], shape, clockwise, innerRadius, (i+1) / setSize); + makeStaticShapeGauge(x + i * spacingX, y, colors[i], shape, clockwise, innerRadius, (i+1) / setSize); case ASSET(asset): for (i in 0...setSize) - makeStaticAssetGuage(x + i * spacingX, y, asset, clockwise, (i+1) / setSize, colors[i]); + makeStaticAssetGauge(x + i * spacingX, y, asset, clockwise, (i+1) / setSize, colors[i]); case MAKE: - final graphic = FlxG.bitmap.get("make-guage"); + final graphic = FlxG.bitmap.get("make-gauge"); for (i in 0...setSize) - makeStaticAssetGuage(x + i * spacingX, y, graphic, clockwise, (i+1) / setSize, colors[i]); + makeStaticAssetGauge(x + i * spacingX, y, graphic, clockwise, (i+1) / setSize, colors[i]); } } var y = 10; - inline function makeStaticRow(graphic:GuageGraphic) + inline function makeStaticRow(graphic:GaugeGraphic) { makeStaticSet(10, y, graphic, true); makeStaticSet(spacingX * setSize + 10, y, graphic, false); @@ -90,32 +90,32 @@ class GuageState extends FlxState makeStaticRow(MAKE); var x = 10; - final tweened = new FlxTypedGroup(); - inline function makeTweened(graphic:GuageGraphic, clockwise = true, color = FlxColor.WHITE) + final tweened = new FlxTypedGroup(); + inline function makeTweened(graphic:GaugeGraphic, clockwise = true, color = FlxColor.WHITE) { - final guage = switch (graphic) + final gauge = switch (graphic) { case SHAPE(shape, innerRadius): - final guage = new FlxPieGuage(x, y); - guage.makePieDialGraphic(shape, 25, innerRadius, color); - guage; + final gauge = new FlxRadialGauge(x, y); + gauge.makePieDialGraphic(shape, 25, innerRadius, color); + gauge; case ASSET(asset): - new FlxPieGuage(x, y, asset); + new FlxRadialGauge(x, y, asset); case MAKE: - final guage = new FlxPieGuage(x, y, FlxG.bitmap.get("make-guage")); - guage.color = color; - guage; + final gauge = new FlxRadialGauge(x, y, FlxG.bitmap.get("make-gauge")); + gauge.color = color; + gauge; } if (!clockwise) { - guage.setOrientation(270, -90); + gauge.setOrientation(270, -90); } - tweened.add(guage); + tweened.add(gauge); x += spacingX; - return guage; + return gauge; } add(tweened); @@ -147,9 +147,9 @@ class GuageState extends FlxState } } -enum GuageGraphic +enum GaugeGraphic { - SHAPE(shape:FlxPieGuageShape, ?innerRadius:Int); + SHAPE(shape:FlxRadialGaugeShape, ?innerRadius:Int); ASSET(asset:FlxGraphicAsset); MAKE; } diff --git a/Features/FlxPieDial/source/Main.hx b/Features/FlxPieDial/source/Main.hx index ef266f628..826e98865 100644 --- a/Features/FlxPieDial/source/Main.hx +++ b/Features/FlxPieDial/source/Main.hx @@ -8,6 +8,11 @@ class Main extends Sprite public function new() { super(); + #if flash addChild(new FlxGame(800, 500, DemoState)); + #else + addChild(new FlxGame(800, 500, GaugeState)); + #end + } }