Skip to content

Commit

Permalink
rename and check flash
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Sep 26, 2024
1 parent 26c94dd commit bcdb751
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,80 @@ 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;
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];
final spacingX = 66;
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);
Expand All @@ -90,32 +90,32 @@ class GuageState extends FlxState
makeStaticRow(MAKE);

var x = 10;
final tweened = new FlxTypedGroup<FlxPieGuage>();
inline function makeTweened(graphic:GuageGraphic, clockwise = true, color = FlxColor.WHITE)
final tweened = new FlxTypedGroup<FlxRadialGauge>();
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);

Expand Down Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions Features/FlxPieDial/source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
}

0 comments on commit bcdb751

Please # to comment.