Namespace: event

me. event

There is no constructor function for me.event
Source:
minpubsub.src.js, line 10

Members

<constant> DRAGEND :String

Channel Constant for dragend events on a Draggable entity
Data passed: {Object} the drag event
{Object} the Draggable entity
Type:
  • String
Source:
minpubsub.src.js, line 226

<constant> DRAGSTART :String

Channel Constant for dragstart events on a Draggable entity
Data passed: {Object} the drag event
{Object} the Draggable entity
Type:
  • String
Source:
minpubsub.src.js, line 214

<constant> GAME_INIT :String

Channel Constant for when the game manager is initialized
Data passed : none
Type:
  • String
Source:
minpubsub.src.js, line 69

<constant> GAME_RESET :String

Channel Constant for when the game manager is resetted
Data passed : none
Type:
  • String
Source:
minpubsub.src.js, line 79

<constant> GAMEPAD_CONNECTED :String

Channel Constant for when a gamepad is connected
Data passed : {Object} gamepad object
Type:
  • String
Source:
minpubsub.src.js, line 170

<constant> GAMEPAD_DISCONNECTED :String

Channel Constant for when a gamepad is disconnected
Data passed : {Object} gamepad object
Type:
  • String
Source:
minpubsub.src.js, line 180

<constant> GAMEPAD_UPDATE :String

Channel Constant for when gamepad button/axis state is updated
Data passed : {Number} index
Data passed : {String} type : "axes" or "buttons"
Data passed : {Number} button
Data passed : {Number} current.value
Data passed : {Boolean} current.pressed
Type:
  • String
Source:
minpubsub.src.js, line 190

<constant> KEYDOWN :String

Channel Constant for pressing a binded key
Data passed : {String} user-defined action, {Number} keyCode, {Boolean} edge state
Edge-state is for detecting "locked" key bindings. When a locked key is pressed and held, the first event will have the third argument set true. Subsequent events will continue firing with the third argument set false.
Type:
  • String
Source:
minpubsub.src.js, line 119
Example
me.input.bindKey(me.input.KEY.X, "jump", true); // Edge-triggered
me.input.bindKey(me.input.KEY.Z, "shoot"); // Level-triggered
me.event.subscribe(me.event.KEYDOWN, function (action, keyCode, edge) {
  // Checking bound keys
  if (action === "jump") {
      if (edge) {
          this.doJump();
      }

      // Make character fall slower when holding the jump key
      this.vel.y = this.body.gravity;
  }
});

<constant> KEYUP :String

Channel Constant for releasing a binded key
Data passed : {String} user-defined action, {Number} keyCode
Type:
  • String
Source:
minpubsub.src.js, line 148
Example
me.event.subscribe(me.event.KEYUP, function (action, keyCode) {
  // Checking unbound keys
  if (keyCode == me.input.KEY.ESC) {
      if (me.state.isPaused()) {
          me.state.resume();
      }
      else {
          me.state.pause();
      }
  }
});

<constant> LEVEL_LOADED :String

Channel Constant for when a level is loaded
Data passed : {String} Level Name
Type:
  • String
Source:
minpubsub.src.js, line 89

<constant> LOADER_COMPLETE :String

Channel Constant for when everything has loaded
Data passed : none
Type:
  • String
Source:
minpubsub.src.js, line 99

<constant> LOADER_PROGRESS :String

Channel Constant for displaying a load progress indicator
Data passed : {Number} [0 .. 1], {Resource} resource object
Type:
  • String
Source:
minpubsub.src.js, line 109

<constant> POINTERMOVE :String

Channel Constant for pointermove events on the viewport area
Data passed : {Object} the Event object
Type:
  • String
Source:
minpubsub.src.js, line 204

<constant> STATE_PAUSE :String

Channel Constant when the game is paused
Data passed : none
Type:
  • String
Source:
minpubsub.src.js, line 29

<constant> STATE_RESTART :String

Channel Constant for when the game is restarted
Data passed : {Number} time in ms the game was stopped
Type:
  • String
Source:
minpubsub.src.js, line 59

<constant> STATE_RESUME :String

Channel Constant for when the game is resumed
Data passed : {Number} time in ms the game was paused
Type:
  • String
Source:
minpubsub.src.js, line 39

<constant> STATE_STOP :String

Channel Constant when the game is stopped
Data passed : none
Type:
  • String
Source:
minpubsub.src.js, line 49

<constant> VIEWPORT_ONCHANGE :String

Channel Constant for when the viewport position is updated
Data passed : {me.Vector2d} viewport position vector
Type:
  • String
Source:
minpubsub.src.js, line 280

<constant> VIEWPORT_ONRESIZE :String

Channel Constant for when the viewport is resized
(this usually follows a WINDOW_ONRESIZE event, when using the `flex` scaling mode is used and after the viewport was updated).
Data passed : {Number} viewport width
Data passed : {Number} viewport height
Type:
  • String
Source:
minpubsub.src.js, line 248

<constant> WINDOW_ONORIENTATION_CHANGE :String

Channel Constant for when the device is rotated
Data passed : {Event} Event object
Type:
  • String
Source:
minpubsub.src.js, line 260

<constant> WINDOW_ONRESIZE :String

Channel Constant for when the (browser) window is resized
Data passed : {Event} Event object
Type:
  • String
Source:
minpubsub.src.js, line 238

<constant> WINDOW_ONSCROLL :String

Channel Constant for when the (browser) window is scrolled
Data passed : {Event} Event object
Type:
  • String
Source:
minpubsub.src.js, line 270

Methods

publish(channel, arguments)

Publish some data on a channel
Parameters:
Name Type Description
channel String The channel to publish on
arguments Array The data to publish
Source:
minpubsub.src.js, line 290
Example
Publish stuff on '/some/channel'.
Anything subscribed will be called with a function
signature like: function (a,b,c){ ... }

me.event.publish("/some/channel", ["a","b","c"]);

subscribe(channel, callback) → {handle}

Register a callback on a named channel.
Parameters:
Name Type Description
channel String The channel to subscribe to
callback function The event handler, any time something is published on a subscribed channel, the callback will be called with the published array as ordered arguments
Source:
minpubsub.src.js, line 315
Returns:
A handle which can be used to unsubscribe this particular subscription
Type
handle
Example
me.event.subscribe("/some/channel", function (a, b, c){ doSomething(); });

unsubscribe(handle, callback)

Disconnect a subscribed function for a channel.
Parameters:
Name Type Argument Description
handle Array | String The return value from a subscribe call or the name of a channel as a String
callback function <optional>
The callback to be unsubscribed.
Source:
minpubsub.src.js, line 338
Example
var handle = me.event.subscribe("/some/channel", function (){});
me.event.unsubscribe(handle);

// Or alternatively ...

var callback = function (){};
me.event.subscribe("/some/channel", callback);
me.event.unsubscribe("/some/channel", callback);
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:40+08:00 using the DocStrap template modified by codename-.