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));
Parameters:
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

Properties inherited from Rect

number
bottom
number
centerX
number
centerY
number
height
number
left
number
right
number
top
string
type = "Rectangle"
number
width

Properties inherited from Polygon

Array<Vector2d>
points

Public Properties


floating uispriteelement.js:76
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)

See: Renderable.floating
holdThreshold uispriteelement.js:51
holdThreshold: number = 250

number

Tap and hold threshold timeout in ms

hover uispriteelement.js:65
hover: boolean = false

boolean

true if the pointer is over the object

isClickable uispriteelement.js:44
isClickable: boolean = true

boolean

object can be clicked or not

isHoldable uispriteelement.js:58
isHoldable: boolean = false

boolean

object can be tap and hold

Public Methods


onClick uispriteelement.js:107
onClick(event: Pointer) → {boolean}

function called when the object is pressed (to be extended)

Parameters:
Name Type Description
event Pointer

the event object

Returns:
Type Description
boolean

return false if we need to stop propagating the event

onHold uispriteelement.js:188
onHold() → {}

function called when the object is pressed and held
to be extended

onOut uispriteelement.js:145
onOut(event: Pointer) → {}

function called when the pointer is leaving the object area

Parameters:
Name Type Description
event Pointer

the event object

onOver uispriteelement.js:126
onOver(event: Pointer) → {}

function called when the pointer is over the object

Parameters:
Name Type Description
event Pointer

the event object

onRelease uispriteelement.js:167
onRelease() → {boolean}

function called when the object is pressed and released (to be extended)

Returns:
Type Description
boolean

return false if we need to stop propagating the event


Powered by webdoc!