UISpriteElement
class UISpriteElement extends Sprite
This is a basic sprite based button which you can use in your Game UI.
Constructor
new UISpriteElement(x: number, y: number, settings: object) → {}
// create a basic GUI Object
class myButton extends UISpriteElement {
constructor(x, y) {
// call the UISpriteElement parent constructor
super(x, y, {
image: "button",
framewidth: 100,
frameheight: 50
});
}
// output something in the console
// when the object is clicked
onClick(event) {
console.log("clicked!");
// don't propagate the event
return false;
}
});
// add the object at pos (10,10)
world.addChild(new myButton(10,10));
Name | Type | Description |
---|---|---|
x | number |
the x coordinate of the UISpriteElement Object |
y | number |
the y coordinate of the UISpriteElement Object |
settings | object |
See Sprite |
Summary
Properties from UISpriteElement
boolean |
|
number |
|
boolean |
|
boolean |
|
boolean |
|
Methods from UISpriteElement
boolean |
|
|
|
|
|
|
|
boolean |
|
Properties inherited from Sprite
boolean |
|
number |
|
boolean |
|
Vector2d |
|
TextureAtlas |
|
Properties inherited from Renderable
number |
|
boolean |
|
Container | Entity |
|
ObservableVector2d |
|
boolean |
|
string |
|
Body |
|
Matrix2d |
|
number |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Rect | RoundRect | Polygon | Line | Ellipse |
|
string |
|
Function |
|
Application |
|
ObservableVector3d |
|
GLShader |
|
Color |
|
boolean |
|
Properties inherited from Rect
Methods inherited from Sprite
number |
|
Sprite |
|
number |
|
boolean |
|
boolean |
|
play or resume the current animation or video |
|
play or resume the current animation or video |
|
Sprite |
|
Sprite |
|
Sprite |
|
Sprite |
|
|
|
boolean |
|
Methods inherited from Renderable
Methods inherited from Rect
Rect |
|
Rect |
|
boolean |
|
Rect |
|
boolean |
|
boolean |
|
boolean |
|
Rect |
|
Rect |
|
Polygon |
|
Rect |
|
Methods inherited from Polygon
Array<number> |
|
boolean |
|
Polygon |
|
Polygon |
|
|
|
Polygon |
|
Polygon |
|
Polygon |
|
Public Properties
floating: boolean = true
boolean
if this UISpriteElement should use screen coordinates or local coordinates (Note: any UISpriteElement elements added to a floating parent container should have their floating property to false)
holdThreshold: number = 250
number
Tap and hold threshold timeout in ms
Public Methods
onClick(event: Pointer) → {boolean}
function called when the object is pressed (to be extended)
Name | Type | Description |
---|---|---|
event | Pointer |
the event object |
Type | Description |
---|---|
boolean |
return false if we need to stop propagating the event |
onHold() → {}
function called when the object is pressed and held
to be extended
onOut(event: Pointer) → {}
function called when the pointer is leaving the object area
Name | Type | Description |
---|---|---|
event | Pointer |
the event object |
onOver(event: Pointer) → {}
function called when the pointer is over the object
Name | Type | Description |
---|---|---|
event | Pointer |
the event object |
onRelease() → {boolean}
function called when the object is pressed and released (to be extended)
Type | Description |
---|---|
boolean |
return false if we need to stop propagating the event |