class flixel.addons.ui.FlxButtonPlus extends FlxSpriteGroup

Available on all platforms

A simple button class that calls a function when clicked by the mouse. * * @link http://www.photonstorm.com * @author Richard Davey / Photon Storm

Class Fields

static var HIGHLIGHT:Int

static var NORMAL:Int

static var PRESSED:Int

Instance Fields

var borderColor:Int

The 1px thick border color that is drawn around this button

var offColor:Array<Int>

The color gradient of the button in its in-active (not hovered over) state

var onColor:Array<Int>

The color gradient of the button in its hovered state

var text:String

If this button has text, set this to change the value

function new(?X:Float = 0, ?Y:Float = 0, ?Callback:Void ->Void = null, ?Label:String = null, ?Width:Int = 100, ?Height:Int = 20):Void

Creates a new FlxButton object with a gray background * and a callback function on the UI thread. * *

X

The X position of the button. *

Y

The Y position of the button. *

Callback

The function to call whenever the button is clicked. *

Label

Text to display on the button *

Width

The width of the button. *

Height

The height of the button.

function destroy():Void

WARNING: This will remove this object entirely. Use kill() if you * want to disable it temporarily only and reset() it later to revive it. * Called by the game state when state is changed (if this object belongs to the state)

function enterCallback():Void

This function is called when the button is hovered over

function leaveCallback():Void

This function is called when the mouse leaves a hovered button (but didn't click)

function loadButtonGraphic(Normal:FlxSprite, Highlight:FlxSprite):Void

If you wish to replace the two buttons (normal and hovered-over) with FlxSprites, then pass them here. * Note: The pixel data is extract from the passed FlxSprites and assigned locally, it doesn't actually use the sprites * or keep a reference to them. * *

Normal

The FlxSprite to use when the button is in-active (not hovered over) *

Highlight

The FlxSprite to use when the button is hovered-over by the mouse

function onClickCallback():Void

This function is called when the button is clicked.

function update():Void

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

function updateActiveButtonColors(Colors:Array<Int>):Void

If you want to change the color of this button in its active (hovered over) state, then pass a new array of color values

function updateInactiveButtonColors(Colors:Array<Int>):Void

If you want to change the color of this button in its in-active (not hovered over) state, then pass a new array of color values