Skip to content

Instantly share code, notes, and snippets.

/ClassBar.hx Secret

Created January 25, 2017 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/428c8e87752bc8165c7d5a1f8f774d26 to your computer and use it in GitHub Desktop.
Save anonymous/428c8e87752bc8165c7d5a1f8f774d26 to your computer and use it in GitHub Desktop.
package classes.utils;
import flixel.ui.FlxBar;
@:enum
abstract BarType(Int) from Int to Int {
var GAME_STATE_SCORE_BAR = 0;
var SETTINGS_VOLUME_BAR = 1;
}
class ClassBar extends FlxBar
{
@:isVar public var barID(get, set):BarType;
public function new(xpos:Float,ypos:Float,max:Int,barID:BarType)
{
super(xpos, ypos);
FlxBarFillDirection.LEFT_TO_RIGHT;
this.min = 0;
this.max = max;
this.barID = barID;
setRange(min, max);
switch(barID) {
case GAME_STATE_SCORE_BAR:
{
createImageBar(AssetPaths.emptyScoreStarBarBG__png, AssetPaths.fullScoreStarFG__png);
pxPerPercent = 4;
}
case SETTINGS_VOLUME_BAR:
{
createImageBar(AssetPaths.emptyBar300x50__png, AssetPaths.fullBar300x50__png);
}
}
percent = 100;
}
public function getMax():Int
{
return Math.floor(max);
}
public function setMax(Max:Int):Void
{
max = Max;
setRange(min,max);
}
public function get_barID():BarType
{
return barID;
}
public function set_barID(value:BarType):BarType
{
return barID = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment