geButton
From GriffinEngine
A simple 2D button implementation. Callback functions can be assigned to be called when mouse is over/out/pressed/released. Note that the actual active area might not match the appearance of the button if rotation/scaling is applied.
Usage
Inheritance
Base classes
- geObject
- geObject2D
- geSprite2D
- geButton
- geSprite2D
- geObject2D
Reference
Fields
- Note: All coordinates are in pixels, relative to top-left corner of the window. Rotation is not supported in buttons.
- ↖
double x; // x coordinate (px)
- ↖
double y; // y coordinate (px)
- ↖
double s; // scale - around axis point
- ↖
double w; // width (px)
- ↖
double h; // height (px)
- ↖
double alignX; // horizontal alignment offset - use Align() to set these
- ↖
double alignY; // vertical alignment offset
- ↖
double axisX; // horizontal axis offset - use SetAxis() to set these
- ↖
double axisY; // vertical axis offset
- ↖
bool active; // indicates whether object should be active/visible
- ↖
geSprite* sprite; // currently displayed sprite
geSprite* normalSprite; // sprite to display when idle
geSprite* hoverSprite; // sprite to display when mouse is over the button
geSprite* downSprite; // sprite to display when the button is being pressed
geCallback onMouseOver; // callback function for when mouse moves over the button (optional)
geCallback onMouseOut; // callback function for when mouse moves outside the button (optional)
geCallback onPress; // callback function for when mouse is pressed on the button (optional)
geCallback onRelease; // callback function for when mouse is pressed on the button (optional)
bool pressed; // true if button is being pressed
bool hovered; // true if mouse is over the button
Constructors
geButton( double _x=0, double _y=0, double _w=0, double _h=0, geSprite* _normalSprite=0 );
geButton( const geButton& original ); // copy constructor
Methods
- ↖
virtual void Align( int alignment = GE_ALIGN_TL, double _alignX = 0, double _alignY = 0 );
- ↖
virtual void SetAxis( int axis = GE_ALIGN_CENTER, double _axisX = 0, double _axisY = 0 );
HUD |
---|
geHUD |
geAnim2D · geButton · geCircle · geObject2D · geSprite2D · geText2D |