C# Class XnaFlixel.FlxButton

A simple button class that calls a function when clicked by the mouse. Supports labels, highlight states, and parallax scrolling.
Inheritance: FlxGroup
Afficher le fichier Open project: jsbeckr/XnaFlixel

Protected Properties

Свойство Type Description
_callback FlxButtonClick
_initialized bool
_off FlxSprite
_offT FlxText
_on FlxSprite
_onT FlxText
_onToggle bool
_pressed bool
_sf Microsoft.Xna.Framework.Vector2

Méthodes publiques

Méthode Description
Destroy ( ) : void

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

FlxButton ( int x, int y, FlxButtonClick callback ) : Microsoft.Xna.Framework

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

LoadGraphic ( FlxSprite image, FlxSprite imageHighlight ) : FlxButton

Set your own image as the button background.

LoadText ( FlxText text, FlxText textHighlight ) : FlxButton

Add a text label to the button.

Render ( SpriteBatch spriteBatch ) : void
Update ( ) : void

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

Méthodes protégées

Méthode Description
visibility ( bool on ) : void

Internal function for handling the visibility of the off and on graphics.

Private Methods

Méthode Description
OnMouseUp ( object sender, FlxMouseEvent mouseEvent ) : void

Internal function for handling the actual callback call (for UI thread dependent calls like FlxU.openURL()).

Method Details

Destroy() public méthode

Called by the game state when state is changed (if this object belongs to the state)
public Destroy ( ) : void
Résultat void

FlxButton() public méthode

Creates a new FlxButton object with a gray background and a callback function on the UI thread.
public FlxButton ( int x, int y, FlxButtonClick callback ) : Microsoft.Xna.Framework
x int The X position of the button.
y int The Y position of the button.
callback FlxButtonClick The function to call whenever the button is clicked.
Résultat Microsoft.Xna.Framework

LoadGraphic() public méthode

Set your own image as the button background.
public LoadGraphic ( FlxSprite image, FlxSprite imageHighlight ) : FlxButton
image FlxSprite A FlxSprite object to use for the button background.
imageHighlight FlxSprite A FlxSprite object to use for the button background when highlighted (optional).
Résultat FlxButton

LoadText() public méthode

Add a text label to the button.
public LoadText ( FlxText text, FlxText textHighlight ) : FlxButton
text FlxText A FlxText object to use to display text on this button (optional).
textHighlight FlxText A FlxText object that is used when the button is highlighted (optional).
Résultat FlxButton

Render() public méthode

public Render ( SpriteBatch spriteBatch ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
Résultat void

Update() public méthode

Called by the game loop automatically, handles mouseover and click detection.
public Update ( ) : void
Résultat void

visibility() protected méthode

Internal function for handling the visibility of the off and on graphics.
protected visibility ( bool on ) : void
on bool Whether the button should be on or off.
Résultat void

Property Details

_callback protected_oe property

This function is called when the button is clicked.
protected FlxButtonClick _callback
Résultat FlxButtonClick

_initialized protected_oe property

Whether or not the button has initialized itself yet.
protected bool _initialized
Résultat bool

_off protected_oe property

Stores the 'off' or normal button state graphic.
protected FlxSprite _off
Résultat FlxSprite

_offT protected_oe property

Stores the 'off' or normal button state label.
protected FlxText _offT
Résultat FlxText

_on protected_oe property

Stores the 'on' or highlighted button state graphic.
protected FlxSprite _on
Résultat FlxSprite

_onT protected_oe property

Stores the 'on' or highlighted button state label.
protected FlxText _onT
Résultat FlxText

_onToggle protected_oe property

Used for checkbox-style behavior.
protected bool _onToggle
Résultat bool

_pressed protected_oe property

Tracks whether or not the button is currently pressed.
protected bool _pressed
Résultat bool

_sf protected_oe property

Helper variable for correcting its members' scrollFactor objects.
protected Vector2,Microsoft.Xna.Framework _sf
Résultat Microsoft.Xna.Framework.Vector2