me.GUI_Object(x, y, settings)

new GUI_Object(x, y, settings)

GUI Object
A very basic object to manage GUI elements
The object simply register on the "pointerdown"
or "touchstart" event and call the onClick function"

Parameters:
Name Type Description
x Number

the x coordinate of the GUI Object

y Number

the y coordinate of the GUI Object

settings Object

See me.Sprite

Example
// create a basic GUI Object
var myButton = me.GUI_Object.extend(
{
   init:function (x, y)
   {
      var settings = {}
      settings.image = "button";
      settings.framewidth = 100;
      settings.frameheight = 50;
      // super constructor
      this._super(me.GUI_Object, "init", [x, y, settings]);
      // define the object z order
      this.pos.z = 4;
   },

   // output something in the console
   // when the object is clicked
   onClick:function (event)
   {
      console.log("clicked!");
      // don't propagate the event
      return false;
   }
});

// add the object at pos (10,10)
me.game.world.addChild(new myButton(10,10));

Extends

Members

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn

Inherited From:
Default Value:
  • 1.0
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container|me.Entity

a reference to the parent object that contains this renderable

Inherited From:
Default Value:
  • undefined

animationpause :Boolean

pause and resume animation

Inherited From:
Default Value:
  • false

animationspeed :Number

animation cycling speed (delay between frame in ms)

Inherited From:
Default Value:
  • 100

holdThreshold :number

Tap and hold threshold timeout in ms

Default Value:
  • 250

hover :boolean

true if the pointer is over the object

Default Value:
  • false

isClickable :boolean

object can be clicked or not

Default Value:
  • true

isHoldable :boolean

object can be tap and hold

Default Value:
  • false

Methods

static onClick(event)

function called when the object is pressed
to be extended
return false if we need to stop propagating the event

Parameters:
Name Type Description
event Event

the event object

static onHold()

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

static onOut(event)

function called when the pointer is leaving the object area

Parameters:
Name Type Description
event Event

the event object

static onOver(event)

function called when the pointer is over the object

Parameters:
Name Type Description
event Event

the event object

static onRelease(event)

function called when the object is pressed and released
to be extended
return false if we need to stop propagating the event

Parameters:
Name Type Description
event Event

the event object