Class Button
Extends
View.
button !CONSTRUCTOR PARAMETERS ARE PROVIDED IN A OBJECT LITERAL!
Defined in: gamejs-gui.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Button(image, image_down, image_hover, text, font, parent, size, position, surface, visible)
|
Field Attributes | Field Name and Description |
---|---|
Label obejct, created if text was provided.
|
|
Method Attributes | Method Name and Description |
---|---|
onClick(callback, scope)
short hand for on(EVT_BTN_CLICK, callback, scope)
|
|
paint()
default button paint implementation paints image, image_down or image_hover based on button sotate
|
|
setText(text)
set button text
|
- Methods borrowed from class View:
- addChild, blitChild, center, despatchEvent, destroy, draw, getGUI, getPosition, getRect, getSize, hide, isFocused, isHovered, isVisible, move, moveRelative, on, refresh, removeChild, resize, show, update
Class Detail
Button(image, image_down, image_hover, text, font, parent, size, position, surface, visible)
- Parameters:
- {gamejs.Surface} image
- button image, OPTIONAL
- {gamejs.Surface} image_down
- button image when pressed down, OPTIONAL
- {gamejs.Surface} image_hover
- button image when hovered on, OPTIONAL
- {String} text
- text to display on button, OPTIONAL
- {CachedFont} font
- to render text with, OPTIONAL
- {View} parent
- parent element
- {Array} size
- array containing width & height of the element, eg. [width, height]
- {Array} position
- position of the view relative to parent, eg. [x, y]. OPTIONAL, default [0, 0]
- {gamejs.Surface} surface
- surface to render this view on, OPTIONAL
- {Bool} visible
- is this view visible? default true
Field Detail
{CachedFont}
font
{Label}
label
Label obejct, created if text was provided.
{String}
text
Method Detail
onClick(callback, scope)
short hand for on(EVT_BTN_CLICK, callback, scope)
- Parameters:
- {Function} callback
- function to call when EVT_BTN_CLICK event is triggered
- {Object} scope
- this object for callback, OPTIONAL
paint()
default button paint implementation paints image, image_down or image_hover based on button sotate
setText(text)
set button text
- Parameters:
- {String} text