class flixel.ui.FlxTypedButton<T> extends FlxSprite

Available on all platforms

A simple button class that calls a function when clicked by the mouse.

Instance Fields

var allowHighlightOnMobile:Bool

Whether to allow the HIHGLIGHT frame of the button graphic to be used on mobile * (false by default, the NORMAL graphic is used instead then).

var allowSwiping:Bool

Whether you can press the button simply by releasing the touch / mouse button over it (default). * If false, the input has to be pressed while hovering over the button.

var label:T

The label that appears on the button. Can be any FlxSprite.

var labelAlphas:Array<Float>

What alpha value the label should have for each status. Default is [0.8, 1.0, 0.5].

var labelOffsets:Array<FlxPoint>

What offsets the label should have for each status.

var onDown:FlxButtonEvent

The properties of this button's onDown event (callback function, sound).

var onOut:FlxButtonEvent

The properties of this button's onOut event (callback function, sound).

var onOver:FlxButtonEvent

The properties of this button's onOver event (callback function, sound).

var onUp:FlxButtonEvent

The properties of this button's onUp event (callback function, sound).

var status:Int

Shows the current state of the button, either FlxButton.NORMAL, * FlxButton.HIGHLIGHT or FlxButton.PRESSED.

function new(?X:Float = 0, ?Y:Float = 0, ?OnClick:Void ->Void = null):Void

Creates a new FlxTypedButton object with a gray background. * *

X

The X position of the button. *

Y

The Y position of the button. *

OnClick

The function to call whenever the button is clicked.

function destroy():Void

Called by the game state when state is changed (if this object belongs to the state)

function draw():Void

Just draws the button graphic and text label to the screen.

function drawDebug():Void

Helper function to draw the debug graphic for the label as well.

function update():Void

Called by the game loop automatically, handles mouseover and click detection.