Adding docs.

This commit is contained in:
Richard Davey
2013-10-01 13:54:29 +01:00
parent fa15f8015d
commit 305b12d76b
64 changed files with 6268 additions and 2682 deletions
+84 -36
View File
@@ -1,8 +1,36 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.Keyboard
*/
/**
* Phaser - Keyboard constructor.
*
* @class Phaser.Keyboard
* @classdesc A Keyboard object Description.
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
*/
Phaser.Keyboard = function (game) {
/**
* @property {Phaser.Game} game - Local reference to game.
*/
this.game = game;
/**
* @property {Description} _keys - Description.
* @private
*/
this._keys = {};
this._hotkeys = {};
/**
* @property {Description} _capture - Description.
* @private
*/
this._capture = {};
this.callbackContext = this;
@@ -16,42 +44,38 @@ Phaser.Keyboard = function (game) {
Phaser.Keyboard.prototype = {
/**
* @property {Phaser.Game} game - Local reference to game.
*/
game: null,
/**
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
* @type {bool}
* @default
* @property {bool} disabled
*/
disabled: false,
/**
* Description.
* @property {Description} _onKeyDown
* @private
* @default
*/
_onKeyDown: null,
/**
* Description.
* @property {Description} _onKeyUp
* @private
* @default
*/
_onKeyUp: null,
addCallbacks: function (context, onDown, onUp) {
this.callbackContext = context;
this.onDownCallback = onDown;
if (typeof onUp !== 'undefined')
{
this.onUpCallback = onUp;
}
},
addKey: function (keycode) {
this._hotkeys[keycode] = new Phaser.Key(this.game, keycode);
return this._hotkeys[keycode];
},
removeKey: function (keycode) {
delete (this._hotkeys[keycode]);
},
/**
* Description.
* @method start
*/
start: function () {
var _this = this;
@@ -69,6 +93,10 @@ Phaser.Keyboard.prototype = {
},
/**
* Description.
* @method stop
*/
stop: function () {
document.body.removeEventListener('keydown', this._onKeyDown);
@@ -81,6 +109,7 @@ Phaser.Keyboard.prototype = {
* There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll.
* You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser.
* Pass in either a single keycode or an array/hash of keycodes.
* @method addKeyCapture
* @param {Any} keycode
*/
addKeyCapture: function (keycode) {
@@ -99,7 +128,9 @@ Phaser.Keyboard.prototype = {
},
/**
* @param {Number} keycode
* Description.
* @method removeKeyCapture
* @param {number} keycode
*/
removeKeyCapture: function (keycode) {
@@ -107,14 +138,19 @@ Phaser.Keyboard.prototype = {
},
/**
* Description.
* @method clearCaptures
*/
clearCaptures: function () {
this._capture = {};
},
/**
* Description.
* @method processKeyDown
* @param {KeyboardEvent} event
*/
processKeyDown: function (event) {
@@ -168,6 +204,8 @@ Phaser.Keyboard.prototype = {
},
/**
* Description.
* @method processKeyUp
* @param {KeyboardEvent} event
*/
processKeyUp: function (event) {
@@ -197,6 +235,10 @@ Phaser.Keyboard.prototype = {
},
/**
* Description.
* @method reset
*/
reset: function () {
for (var key in this._keys)
@@ -207,8 +249,10 @@ Phaser.Keyboard.prototype = {
},
/**
* @param {Number} keycode
* @param {Number} [duration]
* Description.
* @method justPressed
* @param {number} keycode
* @param {number} [duration]
* @return {bool}
*/
justPressed: function (keycode, duration) {
@@ -224,9 +268,11 @@ Phaser.Keyboard.prototype = {
},
/**
* @param {Number} keycode
* @param {Number} [duration]
/**
* Description.
* @method justReleased
* @param {number} keycode
* @param {number} [duration]
* @return {bool}
*/
justReleased: function (keycode, duration) {
@@ -242,8 +288,10 @@ Phaser.Keyboard.prototype = {
},
/**
* @param {Number} keycode
/**
* Description.
* @method isDown
* @param {number} keycode
* @return {bool}
*/
isDown: function (keycode) {