diff --git a/Docs/conf.json b/Docs/conf.json index cfc7e804..43143f3f 100644 --- a/Docs/conf.json +++ b/Docs/conf.json @@ -3,7 +3,7 @@ "allowUnknownTags": true }, "source": { - "include": [ "../src/Phaser.js", "../src/animation/", "../src/core/", "../src/geom/" ], + "include": [ "../src/Phaser.js", "../src/animation/", "../src/core/", "../src/geom/", "../src/input/Input.js" ], "exclude": [], "includePattern": ".+\\.js(doc)?$", "excludePattern": "(^|\\/|\\\\)_" diff --git a/Docs/out/Animation.js.html b/Docs/out/Animation.js.html index c028b798..a2e1dcdd 100644 --- a/Docs/out/Animation.js.html +++ b/Docs/out/Animation.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -591,7 +595,7 @@ Phaser.Animation.generateFrameNames = function (prefix, min, max, suffix, zeroPa Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/AnimationManager.js.html b/Docs/out/AnimationManager.js.html index 90563ccb..b9ff5c8d 100644 --- a/Docs/out/AnimationManager.js.html +++ b/Docs/out/AnimationManager.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -540,7 +544,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Camera.js.html b/Docs/out/Camera.js.html index 765e9052..ef859c8d 100644 --- a/Docs/out/Camera.js.html +++ b/Docs/out/Camera.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -520,7 +524,7 @@ Object.defineProperty(Phaser.Camera.prototype, "height", { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Circle.js.html b/Docs/out/Circle.js.html index 02a5b67e..c0037758 100644 --- a/Docs/out/Circle.js.html +++ b/Docs/out/Circle.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -638,7 +642,7 @@ Phaser.Circle.intersectsRectangle = function (c, r) { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Frame.js.html b/Docs/out/Frame.js.html index a1354c42..89cf7d32 100644 --- a/Docs/out/Frame.js.html +++ b/Docs/out/Frame.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -328,7 +332,7 @@ Phaser.Animation.Frame.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/FrameData.js.html b/Docs/out/FrameData.js.html index 3511cc40..9c34b36f 100644 --- a/Docs/out/FrameData.js.html +++ b/Docs/out/FrameData.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -402,7 +406,7 @@ Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Game.js.html b/Docs/out/Game.js.html index e3a6ddcd..8e2a95c4 100644 --- a/Docs/out/Game.js.html +++ b/Docs/out/Game.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -643,7 +647,7 @@ Object.defineProperty(Phaser.Game.prototype, "paused", { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Group.js.html b/Docs/out/Group.js.html index a0be5682..ce9faefc 100644 --- a/Docs/out/Group.js.html +++ b/Docs/out/Group.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1324,7 +1328,7 @@ Object.defineProperty(Phaser.Group.prototype, "visible", { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Input.js.html b/Docs/out/Input.js.html new file mode 100644 index 00000000..d38e9ed4 --- /dev/null +++ b/Docs/out/Input.js.html @@ -0,0 +1,1034 @@ + + + + + + Phaser Source: input/Input.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/Input.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Constructor for Phaser Input.
    +* @class Phaser.Input
    +* @classdesc A game specific Input manager that looks after the mouse, keyboard and touch objects.
    +* This is updated by the core game loop.
    +* @constructor
    +* @param {Phaser.Game} game - Current game instance.
    +*/
    +Phaser.Input = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - A reference to the currently running game. 
    +	*/
    +	this.game = game;
    +
    +	/**
    +    * @property {Description} hitCanvas - Description. 
    +    * @default
    +	*/
    +    this.hitCanvas = null;
    +    
    +	/**
    +     * @property {Description} hitContext - Description. 
    +     * @default
    + 	*/
    +    this.hitContext = null;
    +	
    +};
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Input.MOUSE_OVERRIDES_TOUCH = 0;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Input.TOUCH_OVERRIDES_MOUSE = 1;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Input.MOUSE_TOUCH_COMBINE = 2;
    +
    +Phaser.Input.prototype = {
    +
    +    /** 
    +    * @property {Phaser.Game} game
    +    */	
    +    game: null,
    +
    +    /**
    +    * How often should the input pointers be checked for updates?
    +    * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.
    +    * @property {number} pollRate 
    +    * @default
    +    */
    +    pollRate: 0,
    +    
    +    /**
    +     * @property {number} _pollCounter - Description.
    +     * @private
    +     * @default
    +     */
    +    _pollCounter: 0,
    +
    +    /**
    +    * A vector object representing the previous position of the Pointer.
    +    * @property {Vec2} vector
    +    * @default 
    +    **/
    +    _oldPosition: null,
    +
    +    /**
    +    * X coordinate of the most recent Pointer event
    +    * @property {number} _x
    +    * @private
    +    * @default
    +    */
    +    _x: 0,
    +
    +    /**
    +    * Y coordinate of the most recent Pointer event
    +    * @property {number} _y
    +    * @private
    +    * @default
    +    */
    +    _y: 0,
    +
    +    /**
    +    * You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored.
    +    * If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead
    +    * @property {boolean} disabled
    +    * @default
    +    */
    +    disabled: false,
    +
    +    /**
    +    * Controls the expected behaviour when using a mouse and touch together on a multi-input device.
    +    * @property {Description} multiInputOverride
    +    */
    +    multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE,
    +
    +    /**
    +    * A vector object representing the current position of the Pointer.
    +    * @property {Vec2} position
    +    * @default 
    +    **/
    +    position: null,
    +
    +    /**
    +    * A vector object representing the speed of the Pointer. Only really useful in single Pointer games,
    +    * otherwise see the Pointer objects directly.
    +    * @property {Vec2} speed
    +    * @default 
    +    **/
    +    speed: null,
    +
    +    /**
    +    * A Circle object centered on the x/y screen coordinates of the Input.
    +    * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything
    +    * @property {Circle} circle
    +    * @default
    +    **/
    +    circle: null,
    +
    +    /**
    +    * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode.
    +    * In an un-scaled game the values will be x: 1 and y: 1.
    +    * @property {Vec2} scale
    +    * @default
    +    */
    +    scale: null,
    +
    +    /**
    +    * The maximum number of Pointers allowed to be active at any one time.
    +    * For lots of games it's useful to set this to 1.
    +    * @property {number} maxPointers
    +    * @default
    +    */
    +    maxPointers: 10,
    +
    +    /**
    +    * The current number of active Pointers.
    +    * @property {number} currentPointers
    +    * @default
    +    */
    +    currentPointers: 0,
    +
    +    /**
    +    * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke
    +    * @property {number} tapRate
    +    * @default
    +    **/
    +    tapRate: 200,
    +
    +    /**
    +    * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click
    +    * @property {number} doubleTapRate
    +    * @default
    +    **/
    +    doubleTapRate: 300,
    +
    +    /**
    +    * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
    +    * @property {number} holdRate
    +    * @default
    +    **/
    +    holdRate: 2000,
    +
    +    /**
    +    * The number of milliseconds below which the Pointer is considered justPressed
    +    * @property {number} justPressedRate
    +    * @default
    +    **/
    +    justPressedRate: 200,
    +
    +    /**
    +    * The number of milliseconds below which the Pointer is considered justReleased 
    +    * @property {number} justReleasedRate
    +    * @default
    +    **/
    +    justReleasedRate: 200,
    +
    +    /**
    +    * Sets if the Pointer objects should record a history of x/y coordinates they have passed through.
    +    * The history is cleared each time the Pointer is pressed down.
    +    * The history is updated at the rate specified in Input.pollRate
    +    * @property {boolean} recordPointerHistory
    +    * @default
    +    **/
    +    recordPointerHistory: false,
    +
    +    /**
    +    * The rate in milliseconds at which the Pointer objects should update their tracking history
    +    * @property {number} recordRate
    +    * @default
    +    */
    +    recordRate: 100,
    +
    +    /**
    +    * The total number of entries that can be recorded into the Pointer objects tracking history.
    +    * If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.
    +    * @property {number} recordLimit
    +    * @default
    +    */
    +    recordLimit: 100,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Pointer} pointer1
    +    **/
    +    pointer1: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Pointer} pointer2
    +    **/
    +    pointer2: null,
    +
    +    /**
    +    * A Pointer object  
    +    * @property {Pointer} pointer3
    +    **/
    +    pointer3: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Pointer} pointer4
    +    **/
    +    pointer4: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Pointer} pointer5
    +    **/
    +    pointer5: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Pointer} pointer6
    +    **/
    +    pointer6: null,
    +
    +    /**
    +    * A Pointer object  
    +    * @property {Pointer} pointer7
    +    **/
    +    pointer7: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Pointer} pointer8
    +    **/
    +    pointer8: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Pointer} pointer9
    +    **/ 
    +    pointer9: null,
    +
    +    /**
    +    * A Pointer object.
    +    * @property {Pointer} pointer10
    +    **/
    +    pointer10: null,
    +
    +    /**
    +    * The most recently active Pointer object.
    +    * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.
    +    * @property {Pointer} activePointer
    +    * @default
    +    **/
    +    activePointer: null,
    +
    +    /**
    +    * Description.
    +    * @property {Pointer} mousePointer
    +    * @default
    +    **/
    +    mousePointer: null,
    +    
    +    /**
    +    * Description.
    +    * @property {Description} mouse
    +    * @default
    +    **/
    +    mouse: null,
    +    
    +    /**
    +    * Description.
    +    * @property {Description} keyboard
    +    * @default
    +    **/
    +    keyboard: null,
    +    
    +    /**
    +    * Description.
    +    * @property {Description} touch
    +    * @default
    +    **/
    +    touch: null,
    +    
    +    /**
    +    * Description.
    +    * @property {Description} mspointer
    +    * @default
    +    **/
    +    mspointer: null,
    +
    +    /**
    +    * Description.
    +    * @property {Description} onDown
    +    * @default
    +    **/
    +    onDown: null,
    +    
    +    /**
    +    * Description.
    +    * @property {Description} onUp
    +    * @default
    +    **/
    +    onUp: null,
    +    
    +    /**
    +    * Description.
    +    * @property {Description} onTap
    +    * @default
    +    **/
    +    onTap: null,
    +    
    +    /**
    +    * Description.
    +    * @property {Description} onHold
    +    * @default
    +    **/
    +    onHold: null,
    +
    +    //  A linked list of interactive objects, the InputHandler components (belong to Sprites) register themselves with this
    +    interactiveItems: new Phaser.LinkedList(),
    +
    +	/**
    +    * Starts the Input Manager running.
    +    * @method Phaser.Input#boot
    +    * @protected
    +    **/
    +    boot: function () {
    +
    +	    this.mousePointer = new Phaser.Pointer(this.game, 0);
    +	    this.pointer1 = new Phaser.Pointer(this.game, 1);
    +	    this.pointer2 = new Phaser.Pointer(this.game, 2);
    +
    +	    this.mouse = new Phaser.Mouse(this.game);
    +	    this.keyboard = new Phaser.Keyboard(this.game);
    +	    this.touch = new Phaser.Touch(this.game);
    +	    this.mspointer = new Phaser.MSPointer(this.game);
    +
    +	    this.onDown = new Phaser.Signal();
    +	    this.onUp = new Phaser.Signal();
    +	    this.onTap = new Phaser.Signal();
    +	    this.onHold = new Phaser.Signal();
    +
    +	    this.scale = new Phaser.Point(1, 1);
    +	    this.speed = new Phaser.Point();
    +	    this.position = new Phaser.Point();
    +	    this._oldPosition = new Phaser.Point();
    +
    +	    this.circle = new Phaser.Circle(0, 0, 44);
    +
    +	    this.activePointer = this.mousePointer;
    +	    this.currentPointers = 0;
    +
    +	    this.hitCanvas = document.createElement('canvas');
    +	    this.hitCanvas.width = 1;
    +	    this.hitCanvas.height = 1;
    +        this.hitContext = this.hitCanvas.getContext('2d');
    +
    +        this.mouse.start();
    +        this.keyboard.start();
    +        this.touch.start();
    +        this.mspointer.start();
    +        this.mousePointer.active = true;
    +
    +    },
    +
    +	/**
    +    * Add a new Pointer object to the Input Manager. By default Input creates 2 pointer objects for you. If you need more
    +    * use this to create a new one, up to a maximum of 10.
    +    * @method Phaser.Input#addPointer
    +    * @return {Pointer} A reference to the new Pointer object.
    +    **/
    +    addPointer: function () {
    +
    +        var next = 0;
    +
    +        for (var i = 10; i > 0; i--)
    +        {
    +            if (this['pointer' + i] === null)
    +            {
    +                next = i;
    +            }
    +        }
    +
    +        if (next == 0)
    +        {
    +            console.warn("You can only have 10 Pointer objects");
    +            return null;
    +        }
    +        else
    +        {
    +            this['pointer' + next] = new Phaser.Pointer(this.game, next);
    +            return this['pointer' + next];
    +        }
    +
    +    },
    +
    +	/**
    +    * Updates the Input Manager. Called by the core Game loop.
    +    * @method Phaser.Input#update
    +    * @protected
    +    **/
    +    update: function () {
    +
    +        if (this.pollRate > 0 && this._pollCounter < this.pollRate)
    +        {
    +            this._pollCounter++;
    +            return;
    +        }
    +
    +        this.speed.x = this.position.x - this._oldPosition.x;
    +        this.speed.y = this.position.y - this._oldPosition.y;
    +
    +        this._oldPosition.copyFrom(this.position);
    +        this.mousePointer.update();
    +
    +        this.pointer1.update();
    +        this.pointer2.update();
    +
    +        if (this.pointer3) { this.pointer3.update(); }
    +        if (this.pointer4) { this.pointer4.update(); }
    +        if (this.pointer5) { this.pointer5.update(); }
    +        if (this.pointer6) { this.pointer6.update(); }
    +        if (this.pointer7) { this.pointer7.update(); }
    +        if (this.pointer8) { this.pointer8.update(); }
    +        if (this.pointer9) { this.pointer9.update(); }
    +        if (this.pointer10) { this.pointer10.update(); }
    +
    +        this._pollCounter = 0;
    +    },
    +
    +	/**
    +    * Reset all of the Pointers and Input states
    +    * @method Phaser.Input#reset
    +    * @param {boolean} hard - A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will.
    +    **/
    +    reset: function (hard) {
    +
    +        if (this.game.isBooted == false)
    +        {
    +            return;
    +        }
    +
    +        if (typeof hard == 'undefined') { hard = false; }
    +
    +        this.keyboard.reset();
    +        this.mousePointer.reset();
    +
    +        for (var i = 1; i <= 10; i++)
    +        {
    +            if (this['pointer' + i])
    +            {
    +                this['pointer' + i].reset();
    +            }
    +        }
    +
    +        this.currentPointers = 0;
    +        this.game.stage.canvas.style.cursor = "default";
    +
    +        if (hard == true)
    +        {
    +            this.onDown.dispose();
    +            this.onUp.dispose();
    +            this.onTap.dispose();
    +            this.onHold.dispose();
    +            this.onDown = new Phaser.Signal();
    +            this.onUp = new Phaser.Signal();
    +            this.onTap = new Phaser.Signal();
    +            this.onHold = new Phaser.Signal();
    +
    +            this.interactiveItems.callAll('reset');
    +        }
    +
    +        this._pollCounter = 0;
    +
    +    },
    +
    +    /**
    +    * Resets the speed and old position properties.
    +    * @method Phaser.Input#resetSpeed
    +    * @param {number} x - Sets the oldPosition.x value.
    +    * @param {number} y - Sets the oldPosition.y value.
    +    **/
    +    resetSpeed: function (x, y) {
    +
    +        this._oldPosition.setTo(x, y);
    +        this.speed.setTo(0, 0);
    +
    +    },
    +
    +	/**
    +    * Find the first free Pointer object and start it, passing in the event data.
    +    * @method Phaser.Input#startPointer
    +    * @param {Any} event - The event data from the Touch event.
    +    * @return {Phaser.Pointer} The Pointer object that was started or null if no Pointer object is available.
    +    **/
    +    startPointer: function (event) {
    +
    +        if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers)
    +        {
    +            return null;
    +        }
    +
    +        if (this.pointer1.active == false)
    +        {
    +            return this.pointer1.start(event);
    +        }
    +        else if (this.pointer2.active == false)
    +        {
    +            return this.pointer2.start(event);
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active == false)
    +                {
    +                    return this['pointer' + i].start(event);
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Updates the matching Pointer object, passing in the event data.
    +    * @method Phaser.Input#updatePointer
    +    * @param {Any} event - The event data from the Touch event.
    +    * @return {Phaser.Pointer} The Pointer object that was updated or null if no Pointer object is available.
    +    */
    +    updatePointer: function (event) {
    +
    +        if (this.pointer1.active && this.pointer1.identifier == event.identifier)
    +        {
    +            return this.pointer1.move(event);
    +        }
    +        else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
    +        {
    +            return this.pointer2.move(event);
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
    +                {
    +                    return this['pointer' + i].move(event);
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Stops the matching Pointer object, passing in the event data.
    +    * @method Phaser.Input#stopPointer
    +    * @param {Any} event - The event data from the Touch event.
    +    * @return {Phaser.Pointer} The Pointer object that was stopped or null if no Pointer object is available.
    +    */
    +    stopPointer: function (event) {
    +
    +        if (this.pointer1.active && this.pointer1.identifier == event.identifier)
    +        {
    +            return this.pointer1.stop(event);
    +        }
    +        else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
    +        {
    +            return this.pointer2.stop(event);
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
    +                {
    +                    return this['pointer' + i].stop(event);
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Get the next Pointer object whos active property matches the given state
    +    * @method Phaser.Input#getPointer
    +    * @param {boolean} state - The state the Pointer should be in (false for inactive, true for active).
    +    * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested state.
    +    */
    +    getPointer: function (state) {
    +
    +        state = state || false;
    +
    +        if (this.pointer1.active == state)
    +        {
    +            return this.pointer1;
    +        }
    +        else if (this.pointer2.active == state)
    +        {
    +            return this.pointer2;
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active == state)
    +                {
    +                    return this['pointer' + i];
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Get the Pointer object whos identified property matches the given identifier value.
    +    * @method Phaser.Input#getPointerFromIdentifier
    +    * @param {number} identifier - The Pointer.identifier value to search for.
    +    * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
    +    */
    +    getPointerFromIdentifier: function (identifier) {
    +
    +        if (this.pointer1.identifier == identifier)
    +        {
    +            return this.pointer1;
    +        }
    +        else if (this.pointer2.identifier == identifier)
    +        {
    +            return this.pointer2;
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].identifier == identifier)
    +                {
    +                    return this['pointer' + i];
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Get the distance between two Pointer objects.
    +    * @method Phaser.Input#getDistance
    +    * @param {Pointer} pointer1
    +    * @param {Pointer} pointer2
    +    * @return {Description} Description.
    +    */
    +    getDistance: function (pointer1, pointer2) {
    +        // return Phaser.Vec2Utils.distance(pointer1.position, pointer2.position);
    +    },
    +
    +	/**
    +    * Get the angle between two Pointer objects.
    +    * @method Phaser.Input#getAngle
    +    * @param {Pointer} pointer1
    +    * @param {Pointer} pointer2
    +    * @return {Description} Description.
    +    */
    +    getAngle: function (pointer1, pointer2) {
    +        // return Phaser.Vec2Utils.angle(pointer1.position, pointer2.position);
    +    }
    +
    +};
    +
    +//	Getters / Setters
    +
    +/**
    +* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
    +* @name Phaser.Input#x
    +* @property {number} x - The X coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "x", {
    +
    +    get: function () {
    +        return this._x;
    +    },
    +
    +    set: function (value) {
    +        this._x = Math.floor(value);
    +    }
    +
    +});
    +
    +/**
    +* The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.
    +* @name Phaser.Input#y
    +* @property {number} y - The Y coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "y", {
    +    
    +    get: function () {
    +        return this._y;
    +    },
    +
    +    set: function (value) {
    +        this._y = Math.floor(value);
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Input#pollLocked
    +* @property {boolean} pollLocked - True if the Input is currently poll rate locked.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "pollLocked", {
    +
    +    get: function () {
    +        return (this.pollRate > 0 && this._pollCounter < this.pollRate);
    +    }
    +
    +});
    +
    +/**
    +* The total number of inactive Pointers
    +* @name Phaser.Input#totalInactivePointers
    +* @property {number} totalInactivePointers - The total number of inactive Pointers.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
    +
    +    get: function () {
    +        return 10 - this.currentPointers;
    +    }
    +
    +});
    +
    +/**
    +* The total number of active Pointers
    +* @name Phaser.Input#totalActivePointers
    +* @property {number} totalActivePointers - The total number of active Pointers.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
    +    
    +    get: function () {
    +
    +        this.currentPointers = 0;
    +
    +        for (var i = 1; i <= 10; i++)
    +        {
    +            if (this['pointer' + i] && this['pointer' + i].active)
    +            {
    +                this.currentPointers++;
    +            }
    +        }
    +
    +        return this.currentPointers;
    +
    +    }
    +
    +});
    +
    +/**
    +* The world X coordinate of the most recently active pointer.
    +* @name Phaser.Input#worldX
    +* @property {number} worldX - The world X coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "worldX", {
    +
    +    get: function () {
    +		return this.game.camera.view.x + this.x;
    +    }
    +
    +});
    +
    +/**
    +* The world Y coordinate of the most recently active pointer.
    +* @name Phaser.Input#worldY
    +* @property {number} worldY - The world Y coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "worldY", {
    +
    +    get: function () {
    +		return this.game.camera.view.y + this.y;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.2.0-dev + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/out/LinkedList.js.html b/Docs/out/LinkedList.js.html index 90ff05df..5a293818 100644 --- a/Docs/out/LinkedList.js.html +++ b/Docs/out/LinkedList.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -321,7 +325,7 @@ Phaser.LinkedList.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Parser.js.html b/Docs/out/Parser.js.html index 51189dc7..c9f06d27 100644 --- a/Docs/out/Parser.js.html +++ b/Docs/out/Parser.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -486,7 +490,7 @@ Phaser.Animation.Parser = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Animation.Frame.html b/Docs/out/Phaser.Animation.Frame.html index 12d686ae..0317af56 100644 --- a/Docs/out/Phaser.Animation.Frame.html +++ b/Docs/out/Phaser.Animation.Frame.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -2680,7 +2684,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Animation.FrameData.html b/Docs/out/Phaser.Animation.FrameData.html index 38d98ed6..65f716b4 100644 --- a/Docs/out/Phaser.Animation.FrameData.html +++ b/Docs/out/Phaser.Animation.FrameData.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1627,7 +1631,7 @@ The frames are returned in the output array, or if none is provided in a new Arr Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Animation.Parser.html b/Docs/out/Phaser.Animation.Parser.html index 3580f6d5..1623b480 100644 --- a/Docs/out/Phaser.Animation.Parser.html +++ b/Docs/out/Phaser.Animation.Parser.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1134,7 +1138,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Animation.html b/Docs/out/Phaser.Animation.html index f1d09803..1c2338c5 100644 --- a/Docs/out/Phaser.Animation.html +++ b/Docs/out/Phaser.Animation.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -2511,7 +2515,7 @@ You could use this function to generate those by doing: Phaser.Animation.generat Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.AnimationManager.html b/Docs/out/Phaser.AnimationManager.html index 6c1f7ad9..afe768a5 100644 --- a/Docs/out/Phaser.AnimationManager.html +++ b/Docs/out/Phaser.AnimationManager.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -2335,7 +2339,7 @@ The currentAnim property of the AnimationManager is automatically set to the ani Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Camera.html b/Docs/out/Phaser.Camera.html index 5a83e805..1b2571dc 100644 --- a/Docs/out/Phaser.Camera.html +++ b/Docs/out/Phaser.Camera.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -2762,7 +2766,7 @@ without having to use game.camera.x and game.camera.y.

    Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Circle.html b/Docs/out/Phaser.Circle.html index 4ebbc588..1c986106 100644 --- a/Docs/out/Phaser.Circle.html +++ b/Docs/out/Phaser.Circle.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -4012,7 +4016,7 @@ This method checks the radius distances between the two Circle objects to see if Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Game.html b/Docs/out/Phaser.Game.html index c5a3c4d8..1e1b1cee 100644 --- a/Docs/out/Phaser.Game.html +++ b/Docs/out/Phaser.Game.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1524,7 +1528,7 @@ providing quick access to common functions and handling the boot process.

    -Phaser.Input +Phaser.Input @@ -4199,7 +4203,7 @@ When a game is paused the onPause event is dispatched. When it is resumed the on Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Group.html b/Docs/out/Phaser.Group.html index c821b008..5e40e3ca 100644 --- a/Docs/out/Phaser.Group.html +++ b/Docs/out/Phaser.Group.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -6125,7 +6129,7 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Input.html b/Docs/out/Phaser.Input.html new file mode 100644 index 00000000..e220408a --- /dev/null +++ b/Docs/out/Phaser.Input.html @@ -0,0 +1,7351 @@ + + + + + + Phaser Class: Input + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Input

    +
    + +
    +

    + Input +

    + +

    A game specific Input manager that looks after the mouse, keyboard and touch objects. +This is updated by the core game loop.

    + +
    + +
    +
    + + + + +
    +

    new Input(game)

    + + +
    +
    + + +
    +

    Constructor for Phaser Input.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <static, constant> MOUSE_OVERRIDES_TOUCH :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> MOUSE_TOUCH_COMBINE :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> TOUCH_OVERRIDES_MOUSE :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    _oldPosition

    + + +
    +
    + +
    +

    A vector object representing the previous position of the Pointer.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    vector + + +Vec2 + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    activePointer

    + + +
    +
    + +
    +

    The most recently active Pointer object. +When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    activePointer + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    circle

    + + +
    +
    + +
    +

    A Circle object centered on the x/y screen coordinates of the Input. +Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    circle + + +Circle + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentPointers

    + + +
    +
    + +
    +

    The current number of active Pointers.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentPointers + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    disabled

    + + +
    +
    + +
    +

    You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored. +If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    disabled + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    doubleTapRate

    + + +
    +
    + +
    +

    The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    doubleTapRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 300
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hitCanvas

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hitCanvas + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hitContext

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hitContext + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    holdRate

    + + +
    +
    + +
    +

    The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    holdRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 2000
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    justPressedRate

    + + +
    +
    + +
    +

    The number of milliseconds below which the Pointer is considered justPressed

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    justPressedRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 200
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    justReleasedRate

    + + +
    +
    + +
    +

    The number of milliseconds below which the Pointer is considered justReleased

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    justReleasedRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 200
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    keyboard

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keyboard + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxPointers

    + + +
    +
    + +
    +

    The maximum number of Pointers allowed to be active at any one time. +For lots of games it's useful to set this to 1.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxPointers + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 10
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouse

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouse + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mousePointer

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mousePointer + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mspointer

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mspointer + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    multiInputOverride

    + + +
    +
    + +
    +

    Controls the expected behaviour when using a mouse and touch together on a multi-input device.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    multiInputOverride + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onDown

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onDown + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onHold

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onHold + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onTap

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onTap + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onUp

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onUp + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer1

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer1 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer2

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer2 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer3

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer3 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer4

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer4 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer5

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer5 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer6

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer6 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer7

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer7 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer8

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer8 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer9

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer9 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer10

    + + +
    +
    + +
    +

    A Pointer object.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer10 + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> pollLocked

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pollLocked + + +boolean + + + +

    True if the Input is currently poll rate locked.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pollRate

    + + +
    +
    + +
    +

    How often should the input pointers be checked for updates? +A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pollRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    position

    + + +
    +
    + +
    +

    A vector object representing the current position of the Pointer.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    position + + +Vec2 + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    recordLimit

    + + +
    +
    + +
    +

    The total number of entries that can be recorded into the Pointer objects tracking history. +If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    recordLimit + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 100
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    recordPointerHistory

    + + +
    +
    + +
    +

    Sets if the Pointer objects should record a history of x/y coordinates they have passed through. +The history is cleared each time the Pointer is pressed down. +The history is updated at the rate specified in Input.pollRate

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    recordPointerHistory + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    recordRate

    + + +
    +
    + +
    +

    The rate in milliseconds at which the Pointer objects should update their tracking history

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    recordRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 100
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + +
    +

    The scale by which all input coordinates are multiplied, calculated by the StageScaleMode. +In an un-scaled game the values will be x: 1 and y: 1.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Vec2 + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    speed

    + + +
    +
    + +
    +

    A vector object representing the speed of the Pointer. Only really useful in single Pointer games, +otherwise see the Pointer objects directly.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    speed + + +Vec2 + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    tapRate

    + + +
    +
    + +
    +

    The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tapRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 200
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> totalActivePointers

    + + +
    +
    + +
    +

    The total number of active Pointers

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    totalActivePointers + + +number + + + +

    The total number of active Pointers.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> totalInactivePointers

    + + +
    +
    + +
    +

    The total number of inactive Pointers

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    totalInactivePointers + + +number + + + +

    The total number of inactive Pointers.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touch

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touch + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    worldX

    + + +
    +
    + +
    +

    The world X coordinate of the most recently active pointer.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    worldX + + +number + + + +

    The world X coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    worldY

    + + +
    +
    + +
    +

    The world Y coordinate of the most recently active pointer.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    worldY + + +number + + + +

    The world Y coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + +
    +

    The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The X coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + +
    +

    The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The Y coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    addPointer() → {Pointer}

    + + +
    +
    + + +
    +

    Add a new Pointer object to the Input Manager. By default Input creates 2 pointer objects for you. If you need more +use this to create a new one, up to a maximum of 10.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A reference to the new Pointer object.

    +
    + + + +
    +
    + Type +
    +
    + +Pointer + + +
    +
    + + + + + +
    + + + +
    +

    <protected> boot()

    + + +
    +
    + + +
    +

    Starts the Input Manager running.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getAngle(pointer1, pointer2) → {Description}

    + + +
    +
    + + +
    +

    Get the angle between two Pointer objects.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer1 + + +Pointer + + + +
    pointer2 + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Description.

    +
    + + + +
    +
    + Type +
    +
    + +Description + + +
    +
    + + + + + +
    + + + +
    +

    getDistance(pointer1, pointer2) → {Description}

    + + +
    +
    + + +
    +

    Get the distance between two Pointer objects.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer1 + + +Pointer + + + +
    pointer2 + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Description.

    +
    + + + +
    +
    + Type +
    +
    + +Description + + +
    +
    + + + + + +
    + + + +
    +

    getPointer(state) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Get the next Pointer object whos active property matches the given state

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    state + + +boolean + + + +

    The state the Pointer should be in (false for inactive, true for active).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Pointer object or null if no Pointer object matches the requested state.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    getPointerFromIdentifier(identifier) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Get the Pointer object whos identified property matches the given identifier value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    identifier + + +number + + + +

    The Pointer.identifier value to search for.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Pointer object or null if no Pointer object matches the requested identifier.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    reset(hard)

    + + +
    +
    + + +
    +

    Reset all of the Pointers and Input states

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hard + + +boolean + + + +

    A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    resetSpeed(x, y)

    + + +
    +
    + + +
    +

    Resets the speed and old position properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Sets the oldPosition.x value.

    y + + +number + + + +

    Sets the oldPosition.y value.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    startPointer(event) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Find the first free Pointer object and start it, passing in the event data.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +

    The event data from the Touch event.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Pointer object that was started or null if no Pointer object is available.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    stopPointer(event) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Stops the matching Pointer object, passing in the event data.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +

    The event data from the Touch event.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Pointer object that was stopped or null if no Pointer object is available.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    <protected> update()

    + + +
    +
    + + +
    +

    Updates the Input Manager. Called by the core Game loop.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updatePointer(event) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Updates the matching Pointer object, passing in the event data.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +

    The event data from the Touch event.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Pointer object that was updated or null if no Pointer object is available.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.2.0-dev + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Docs/out/Phaser.LinkedList.html b/Docs/out/Phaser.LinkedList.html index c9337926..863a2142 100644 --- a/Docs/out/Phaser.LinkedList.html +++ b/Docs/out/Phaser.LinkedList.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1179,7 +1183,7 @@ The function must exist on the member.

    Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Plugin.html b/Docs/out/Phaser.Plugin.html index d6e5d47d..191b741c 100644 --- a/Docs/out/Phaser.Plugin.html +++ b/Docs/out/Phaser.Plugin.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1531,7 +1535,7 @@ It is only called if active is set to true.

    Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Point.html b/Docs/out/Phaser.Point.html index 405b7af6..03902aac 100644 --- a/Docs/out/Phaser.Point.html +++ b/Docs/out/Phaser.Point.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -4721,7 +4725,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Rectangle.html b/Docs/out/Phaser.Rectangle.html index e77f6465..46b8f57d 100644 --- a/Docs/out/Phaser.Rectangle.html +++ b/Docs/out/Phaser.Rectangle.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -7062,7 +7066,7 @@ This method checks the x, y, width, and height properties of the Rectangles.

    Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Signal.html b/Docs/out/Phaser.Signal.html index b319e1b8..ef0ec898 100644 --- a/Docs/out/Phaser.Signal.html +++ b/Docs/out/Phaser.Signal.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -2018,7 +2022,7 @@ already dispatched before.

    Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.Stage.html b/Docs/out/Phaser.Stage.html index 06c46fa8..636582f3 100644 --- a/Docs/out/Phaser.Stage.html +++ b/Docs/out/Phaser.Stage.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1207,7 +1211,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.State.html b/Docs/out/Phaser.State.html index 2abdd191..fb816582 100644 --- a/Docs/out/Phaser.State.html +++ b/Docs/out/Phaser.State.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -710,7 +714,7 @@ It provides quick access to common functions such as the camera, cache, input, m -Phaser.Input +Phaser.Input @@ -2298,7 +2302,7 @@ If you need to use the loader, you may need to use them here.

    Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.StateManager.html b/Docs/out/Phaser.StateManager.html index e88858ea..ac9ffc8a 100644 --- a/Docs/out/Phaser.StateManager.html +++ b/Docs/out/Phaser.StateManager.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -3155,7 +3159,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.World.html b/Docs/out/Phaser.World.html index a118f818..020bb9f1 100644 --- a/Docs/out/Phaser.World.html +++ b/Docs/out/Phaser.World.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -1868,7 +1872,7 @@ the world at world-based coordinates. By default a world is created the same siz Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:27 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Phaser.js.html b/Docs/out/Phaser.js.html index 8bd8fd9a..bbfde5f5 100644 --- a/Docs/out/Phaser.js.html +++ b/Docs/out/Phaser.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -209,7 +213,7 @@ PIXI.InteractionManager = function (dummy) { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Plugin.js.html b/Docs/out/Plugin.js.html index bc355e1f..032662d5 100644 --- a/Docs/out/Plugin.js.html +++ b/Docs/out/Plugin.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -283,7 +287,7 @@ Phaser.Plugin.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/PluginManager-Phaser.PluginManager.html b/Docs/out/PluginManager-Phaser.PluginManager.html index caa45d03..5e6d6eec 100644 --- a/Docs/out/PluginManager-Phaser.PluginManager.html +++ b/Docs/out/PluginManager-Phaser.PluginManager.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -548,7 +552,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/PluginManager.html b/Docs/out/PluginManager.html index abcbd9b9..6084a8d3 100644 --- a/Docs/out/PluginManager.html +++ b/Docs/out/PluginManager.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -249,7 +253,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:26 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/PluginManager.js.html b/Docs/out/PluginManager.js.html index 45f1cc08..e8a5418e 100644 --- a/Docs/out/PluginManager.js.html +++ b/Docs/out/PluginManager.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -401,7 +405,7 @@ Phaser.PluginManager.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Point.js.html b/Docs/out/Point.js.html index bf05e2d7..cdf3f1bd 100644 --- a/Docs/out/Point.js.html +++ b/Docs/out/Point.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -563,7 +567,7 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Rectangle.js.html b/Docs/out/Rectangle.js.html index 8ac3b2be..9515f5a4 100644 --- a/Docs/out/Rectangle.js.html +++ b/Docs/out/Rectangle.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -832,7 +836,7 @@ Phaser.Rectangle.union = function (a, b, out) { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Signal.js.html b/Docs/out/Signal.js.html index f10c19d0..92e4f6aa 100644 --- a/Docs/out/Signal.js.html +++ b/Docs/out/Signal.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -465,7 +469,7 @@ Phaser.Signal.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/SignalBinding.html b/Docs/out/SignalBinding.html index 3fe72dd4..3d41330f 100644 --- a/Docs/out/SignalBinding.html +++ b/Docs/out/SignalBinding.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -465,7 +469,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:55 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:27 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/SignalBinding.js.html b/Docs/out/SignalBinding.js.html index 080ffba4..e2bf2418 100644 --- a/Docs/out/SignalBinding.js.html +++ b/Docs/out/SignalBinding.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -330,7 +334,7 @@ Phaser.SignalBinding.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/Stage.js.html b/Docs/out/Stage.js.html index b7f5a656..4e5f83e6 100644 --- a/Docs/out/Stage.js.html +++ b/Docs/out/Stage.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -314,7 +318,7 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/State.js.html b/Docs/out/State.js.html index 0110a04b..4f2ebac7 100644 --- a/Docs/out/State.js.html +++ b/Docs/out/State.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -337,7 +341,7 @@ Phaser.State.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/StateManager.js.html b/Docs/out/StateManager.js.html index ccd7c747..b3636079 100644 --- a/Docs/out/StateManager.js.html +++ b/Docs/out/StateManager.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -693,7 +697,7 @@ Phaser.StateManager.prototype = { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/World.js.html b/Docs/out/World.js.html index 966c784c..e950278a 100644 --- a/Docs/out/World.js.html +++ b/Docs/out/World.js.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -410,7 +414,7 @@ Object.defineProperty(Phaser.World.prototype, "randomY", { Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/classes.list.html b/Docs/out/classes.list.html index 6b090e08..09d1aa16 100644 --- a/Docs/out/classes.list.html +++ b/Docs/out/classes.list.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -231,6 +235,9 @@
    Group
    +
    Input
    +
    +
    LinkedList
    @@ -295,7 +302,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/index.html b/Docs/out/index.html index e5fcf3b9..19393359 100644 --- a/Docs/out/index.html +++ b/Docs/out/index.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -185,7 +189,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/module-Phaser.html b/Docs/out/module-Phaser.html index 7e8141f8..55118b51 100644 --- a/Docs/out/module-Phaser.html +++ b/Docs/out/module-Phaser.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -236,7 +240,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/Docs/out/modules.list.html b/Docs/out/modules.list.html index c7e78d84..88985847 100644 --- a/Docs/out/modules.list.html +++ b/Docs/out/modules.list.html @@ -82,6 +82,10 @@ Group +
  • + Input +
  • +
  • LinkedList
  • @@ -231,6 +235,9 @@
    Group
    +
    Input
    +
    +
    LinkedList
    @@ -295,7 +302,7 @@ Documentation generated by JSDoc 3.2.0-dev - on Wed Oct 02 2013 12:09:54 GMT+0100 (BST) using the DocStrap template. + on Wed Oct 02 2013 12:28:25 GMT+0100 (BST) using the DocStrap template. diff --git a/src/input/Input.js b/src/input/Input.js index 4ac153f3..efe1f7b0 100644 --- a/src/input/Input.js +++ b/src/input/Input.js @@ -2,7 +2,6 @@ * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.Input */ /** @@ -34,8 +33,22 @@ Phaser.Input = function (game) { }; +/** +* @constant +* @type {number} +*/ Phaser.Input.MOUSE_OVERRIDES_TOUCH = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Input.TOUCH_OVERRIDES_MOUSE = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Input.MOUSE_TOUCH_COMBINE = 2; Phaser.Input.prototype = { @@ -63,8 +76,9 @@ Phaser.Input.prototype = { /** * A vector object representing the previous position of the Pointer. * @property {Vec2} vector + * @private * @default - **/ + */ _oldPosition: null, /** @@ -99,31 +113,31 @@ Phaser.Input.prototype = { /** * A vector object representing the current position of the Pointer. - * @property {Vec2} position + * @property {Phaser.Point} position * @default - **/ + */ position: null, /** * A vector object representing the speed of the Pointer. Only really useful in single Pointer games, * otherwise see the Pointer objects directly. - * @property {Vec2} speed + * @property {Phaser.Point} speed * @default - **/ + */ speed: null, /** * A Circle object centered on the x/y screen coordinates of the Input. - * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything - * @property {Circle} circle + * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything. + * @property {Phaser.Circle} circle * @default - **/ + */ circle: null, /** * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode. * In an un-scaled game the values will be x: 1 and y: 1. - * @property {Vec2} scale + * @property {Phaser.Point} scale * @default */ scale: null, @@ -147,35 +161,35 @@ Phaser.Input.prototype = { * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke * @property {number} tapRate * @default - **/ + */ tapRate: 200, /** * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click * @property {number} doubleTapRate * @default - **/ + */ doubleTapRate: 300, /** * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event * @property {number} holdRate * @default - **/ + */ holdRate: 2000, /** * The number of milliseconds below which the Pointer is considered justPressed * @property {number} justPressedRate * @default - **/ + */ justPressedRate: 200, /** * The number of milliseconds below which the Pointer is considered justReleased * @property {number} justReleasedRate * @default - **/ + */ justReleasedRate: 200, /** @@ -184,7 +198,7 @@ Phaser.Input.prototype = { * The history is updated at the rate specified in Input.pollRate * @property {boolean} recordPointerHistory * @default - **/ + */ recordPointerHistory: false, /** @@ -204,142 +218,146 @@ Phaser.Input.prototype = { /** * A Pointer object - * @property {Pointer} pointer1 - **/ + * @property {Phaser.Pointer} pointer1 + */ pointer1: null, /** * A Pointer object - * @property {Pointer} pointer2 - **/ + * @property {Phaser.Pointer} pointer2 + */ pointer2: null, /** * A Pointer object - * @property {Pointer} pointer3 - **/ + * @property {Phaser.Pointer} pointer3 + */ pointer3: null, /** * A Pointer object - * @property {Pointer} pointer4 - **/ + * @property {Phaser.Pointer} pointer4 + */ pointer4: null, /** * A Pointer object - * @property {Pointer} pointer5 - **/ + * @property {Phaser.Pointer} pointer5 + */ pointer5: null, /** * A Pointer object - * @property {Pointer} pointer6 - **/ + * @property {Phaser.Pointer} pointer6 + */ pointer6: null, /** * A Pointer object - * @property {Pointer} pointer7 - **/ + * @property {Phaser.Pointer} pointer7 + */ pointer7: null, /** * A Pointer object - * @property {Pointer} pointer8 - **/ + * @property {Phaser.Pointer} pointer8 + */ pointer8: null, /** * A Pointer object - * @property {Pointer} pointer9 - **/ + * @property {Phaser.Pointer} pointer9 + */ pointer9: null, /** * A Pointer object. - * @property {Pointer} pointer10 - **/ + * @property {Phaser.Pointer} pointer10 + */ pointer10: null, /** * The most recently active Pointer object. * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse. - * @property {Pointer} activePointer + * @property {Phaser.Pointer} activePointer * @default - **/ + */ activePointer: null, /** - * Description. + * The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game. * @property {Pointer} mousePointer * @default - **/ + */ mousePointer: null, /** - * Description. - * @property {Description} mouse + * The Mouse Input manager. + * @property {Phaser.Mouse} mouse - The Mouse Input manager. * @default - **/ + */ mouse: null, /** - * Description. - * @property {Description} keyboard + * The Keyboard Input manager. + * @property {Phaser.Keyboard} keyboard - The Keyboard Input manager. * @default - **/ + */ keyboard: null, /** - * Description. - * @property {Description} touch + * The Touch Input manager. + * @property {Phaser.Touch} touch - the Touch Input manager. * @default - **/ + */ touch: null, /** - * Description. - * @property {Description} mspointer + * The MSPointer Input manager. + * @property {Phaser.MSPointer} mspointer - The MSPointer Input manager. * @default - **/ + */ mspointer: null, /** - * Description. - * @property {Description} onDown + * A Signal that is dispatched each time a pointer is pressed down. + * @property {Phaser.Signal} onDown * @default - **/ + */ onDown: null, /** - * Description. - * @property {Description} onUp + * A Signal that is dispatched each time a pointer is released. + * @property {Phaser.Signal} onUp * @default - **/ + */ onUp: null, /** - * Description. - * @property {Description} onTap + * A Signal that is dispatched each time a pointer is tapped. + * @property {Phaser.Signal} onTap * @default - **/ + */ onTap: null, /** - * Description. - * @property {Description} onHold + * A Signal that is dispatched each time a pointer is held down. + * @property {Phaser.Signal} onHold * @default - **/ + */ onHold: null, - // A linked list of interactive objects, the InputHandler components (belong to Sprites) register themselves with this + /** + * A linked list of interactive objects, the InputHandler components (belonging to Sprites) register themselves with this. + * @property {Phaser.LinkedList} interactiveItems + */ interactiveItems: new Phaser.LinkedList(), /** * Starts the Input Manager running. - * @method start - **/ + * @method Phaser.Input#boot + * @protected + */ boot: function () { this.mousePointer = new Phaser.Pointer(this.game, 0); @@ -380,11 +398,11 @@ Phaser.Input.prototype = { }, /** - * Add a new Pointer object to the Input Manager. By default Input creates 2 pointer objects for you. If you need more - * use this to create a new one, up to a maximum of 10. - * @method addPointer - * @return {Pointer} A reference to the new Pointer object. - **/ + * Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2. + * If you need more then use this to create a new one, up to a maximum of 10. + * @method Phaser.Input#addPointer + * @return {Phaser.Pointer} A reference to the new Pointer object that was created. + */ addPointer: function () { var next = 0; @@ -412,8 +430,9 @@ Phaser.Input.prototype = { /** * Updates the Input Manager. Called by the core Game loop. - * @method update - **/ + * @method Phaser.Input#update + * @protected + */ update: function () { if (this.pollRate > 0 && this._pollCounter < this.pollRate) @@ -445,9 +464,9 @@ Phaser.Input.prototype = { /** * Reset all of the Pointers and Input states - * @method reset - * @param {boolean} hard - A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will. - **/ + * @method Phaser.Input#reset + * @param {boolean} hard - A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will. + */ reset: function (hard) { if (this.game.isBooted == false) @@ -489,6 +508,12 @@ Phaser.Input.prototype = { }, + /** + * Resets the speed and old position properties. + * @method Phaser.Input#resetSpeed + * @param {number} x - Sets the oldPosition.x value. + * @param {number} y - Sets the oldPosition.y value. + */ resetSpeed: function (x, y) { this._oldPosition.setTo(x, y); @@ -497,11 +522,11 @@ Phaser.Input.prototype = { }, /** - * Find the first free Pointer object and start it, passing in the event data. - * @method startPointer + * Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer. + * @method Phaser.Input#startPointer * @param {Any} event - The event data from the Touch event. - * @return {Pointer} The Pointer object that was started or null if no Pointer object is available. - **/ + * @return {Phaser.Pointer} The Pointer object that was started or null if no Pointer object is available. + */ startPointer: function (event) { if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers) @@ -533,11 +558,11 @@ Phaser.Input.prototype = { }, /** - * Updates the matching Pointer object, passing in the event data. - * @method updatePointer + * Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked. + * @method Phaser.Input#updatePointer * @param {Any} event - The event data from the Touch event. - * @return {Pointer} The Pointer object that was updated or null if no Pointer object is available. - **/ + * @return {Phaser.Pointer} The Pointer object that was updated or null if no Pointer object is available. + */ updatePointer: function (event) { if (this.pointer1.active && this.pointer1.identifier == event.identifier) @@ -565,10 +590,10 @@ Phaser.Input.prototype = { /** * Stops the matching Pointer object, passing in the event data. - * @method stopPointer + * @method Phaser.Input#stopPointer * @param {Any} event - The event data from the Touch event. - * @return {Pointer} The Pointer object that was stopped or null if no Pointer object is available. - **/ + * @return {Phaser.Pointer} The Pointer object that was stopped or null if no Pointer object is available. + */ stopPointer: function (event) { if (this.pointer1.active && this.pointer1.identifier == event.identifier) @@ -596,10 +621,10 @@ Phaser.Input.prototype = { /** * Get the next Pointer object whos active property matches the given state - * @method getPointer + * @method Phaser.Input#getPointer * @param {boolean} state - The state the Pointer should be in (false for inactive, true for active). - * @return {Pointer} A Pointer object or null if no Pointer object matches the requested state. - **/ + * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested state. + */ getPointer: function (state) { state = state || false; @@ -629,10 +654,10 @@ Phaser.Input.prototype = { /** * Get the Pointer object whos identified property matches the given identifier value. - * @method getPointerFromIdentifier + * @method Phaser.Input#getPointerFromIdentifier * @param {number} identifier - The Pointer.identifier value to search for. - * @return {Pointer} A Pointer object or null if no Pointer object matches the requested identifier. - **/ + * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier. + */ getPointerFromIdentifier: function (identifier) { if (this.pointer1.identifier == identifier) @@ -660,37 +685,32 @@ Phaser.Input.prototype = { /** * Get the distance between two Pointer objects. - * @method getDistance + * @method Phaser.Input#getDistance * @param {Pointer} pointer1 * @param {Pointer} pointer2 * @return {Description} Description. - **/ + */ getDistance: function (pointer1, pointer2) { // return Phaser.Vec2Utils.distance(pointer1.position, pointer2.position); }, /** * Get the angle between two Pointer objects. - * @method getAngle + * @method Phaser.Input#getAngle * @param {Pointer} pointer1 * @param {Pointer} pointer2 * @return {Description} Description. - **/ + */ getAngle: function (pointer1, pointer2) { // return Phaser.Vec2Utils.angle(pointer1.position, pointer2.position); } }; -// Getters / Setters - /** -* The X coordinate of the most recently active pointer. -* This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. -* @return {number} -*//** -* Set -* @param {number} value - Description. +* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. +* @name Phaser.Input#x +* @property {number} x - The X coordinate of the most recently active pointer. */ Object.defineProperty(Phaser.Input.prototype, "x", { @@ -705,12 +725,9 @@ Object.defineProperty(Phaser.Input.prototype, "x", { }); /** -* The Y coordinate of the most recently active pointer. - * This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. -* @return {number} -*//** -* Set -* @param {number} value - Description. +* The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. +* @name Phaser.Input#y +* @property {number} y - The Y coordinate of the most recently active pointer. */ Object.defineProperty(Phaser.Input.prototype, "y", { @@ -725,8 +742,9 @@ Object.defineProperty(Phaser.Input.prototype, "y", { }); /** -* Get -* @return {Description} Description. +* @name Phaser.Input#pollLocked +* @property {boolean} pollLocked - True if the Input is currently poll rate locked. +* @readonly */ Object.defineProperty(Phaser.Input.prototype, "pollLocked", { @@ -737,8 +755,10 @@ Object.defineProperty(Phaser.Input.prototype, "pollLocked", { }); /** -* Get the total number of inactive Pointers -* @return {number} The number of Pointers currently inactive. +* The total number of inactive Pointers +* @name Phaser.Input#totalInactivePointers +* @property {number} totalInactivePointers - The total number of inactive Pointers. +* @readonly */ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", { @@ -749,8 +769,10 @@ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", { }); /** -* Recalculates the total number of active Pointers -* @return {number} The number of Pointers currently active. +* The total number of active Pointers +* @name Phaser.Input#totalActivePointers +* @property {number} totalActivePointers - The total number of active Pointers. +* @readonly */ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { @@ -773,8 +795,9 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { }); /** -* Get -* @return {Description} +* The world X coordinate of the most recently active pointer. +* @name Phaser.Input#worldX +* @property {number} worldX - The world X coordinate of the most recently active pointer. */ Object.defineProperty(Phaser.Input.prototype, "worldX", { @@ -785,8 +808,9 @@ Object.defineProperty(Phaser.Input.prototype, "worldX", { }); /** -* Get -* @return {Description} +* The world Y coordinate of the most recently active pointer. +* @name Phaser.Input#worldY +* @property {number} worldY - The world Y coordinate of the most recently active pointer. */ Object.defineProperty(Phaser.Input.prototype, "worldY", { diff --git a/src/input/Key.js b/src/input/Key.js index a94bf7d5..b8ad2ab4 100644 --- a/src/input/Key.js +++ b/src/input/Key.js @@ -1,73 +1,92 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @class Phaser.Key +* @classdesc If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects. +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} keycode - The key code this Key is responsible for. +*/ Phaser.Key = function (game, keycode) { + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; /** - * - * @property isDown - * @type Boolean - **/ + * @property {boolean} isDown - The "down" state of the key. + * @default + */ this.isDown = false; /** - * - * @property isUp - * @type Boolean - **/ + * @property {boolean} isUp - The "up" state of the key. + * @default + */ this.isUp = false; /** - * - * @property altKey - * @type Boolean - **/ + * @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key. + * @default + */ this.altKey = false; /** - * - * @property ctrlKey - * @type Boolean - **/ + * @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key. + * @default + */ this.ctrlKey = false; /** - * - * @property shiftKey - * @type Boolean - **/ + * @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key. + * @default + */ this.shiftKey = false; /** - * - * @property timeDown - * @type Number - **/ + * @property {number} timeDown - The timestamp when the key was last pressed down. + * @default + */ this.timeDown = 0; /** - * - * @property duration - * @type Number - **/ + * If the key is down this value holds the duration of that key press and is constantly updated. + * If the key is up it holds the duration of the previous down session. + * @property {number} duration - The number of milliseconds this key has been held down for. + * @default + */ this.duration = 0; /** - * - * @property timeUp - * @type Number - **/ + * @property {number} timeUp - The timestamp when the key was last released. + * @default + */ this.timeUp = 0; /** - * - * @property repeats - * @type Number - **/ + * @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'. + * @default + */ this.repeats = 0; + /** + * @property {number} keyCode - The keycode of this key. + */ this.keyCode = keycode; + /** + * @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ this.onDown = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ this.onUp = new Phaser.Signal(); }; @@ -75,10 +94,10 @@ Phaser.Key = function (game, keycode) { Phaser.Key.prototype = { /** - * - * @method update + * Called automatically by Phaser.Keyboard. + * @method Phaser.Key#processKeyDown * @param {KeyboardEvent} event. - * @return {} + * @protected */ processKeyDown: function (event) { @@ -105,6 +124,12 @@ Phaser.Key.prototype = { }, + /** + * Called automatically by Phaser.Keyboard. + * @method Phaser.Key#processKeyUp + * @param {KeyboardEvent} event. + * @protected + */ processKeyUp: function (event) { this.isDown = false; @@ -116,8 +141,10 @@ Phaser.Key.prototype = { }, /** - * @param {number} [duration] - * @return {boolean} + * Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) + * @method Phaser.Key#justPressed + * @param {number} [duration=250] - The duration below which the key is considered as being just pressed. + * @return {boolean} True if the key is just pressed otherwise false. */ justPressed: function (duration) { @@ -128,8 +155,10 @@ Phaser.Key.prototype = { }, /** - * @param {number} [duration] - * @return {boolean} + * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) + * @method Phaser.Key#justPressed + * @param {number} [duration=250] - The duration below which the key is considered as being just released. + * @return {boolean} True if the key is just released otherwise false. */ justReleased: function (duration) { @@ -139,4 +168,4 @@ Phaser.Key.prototype = { } -}; \ No newline at end of file +}; diff --git a/src/input/Keyboard.js b/src/input/Keyboard.js index a2c1289c..3bc94e5b 100644 --- a/src/input/Keyboard.js +++ b/src/input/Keyboard.js @@ -2,10 +2,8 @@ * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} -* @module Phaser.Keyboard */ - /** * Phaser - Keyboard constructor. * @@ -39,45 +37,53 @@ Phaser.Keyboard = function (game) { */ this._capture = {}; - this.callbackContext = this; - this.onDownCallback = null; - this.onUpCallback = null; + /** + * You can disable all Keyboard Input by setting disabled to true. While true all new input related events will be ignored. + * @property {boolean} disabled - The disabled state of the Keyboard. + * @default + */ + disabled: false, - this.onDown = new Phaser.Signal(); - this.onUp = new Phaser.Signal(); + /** + * @property {function} _onKeyDown + * @private + * @default + */ + _onKeyDown: null, + + /** + * @property {function} _onKeyUp + * @private + * @default + */ + _onKeyUp: null, + + /** + * @property {Object} callbackContext - The context under which the callbacks are run. + */ + this.callbackContext = this; + + /** + * @property {function} onDownCallback - This callback is invoked every time a key is pressed down. + */ + this.onDownCallback = null; + + /** + * @property {function} onUpCallback - This callback is invoked every time a key is released. + */ + this.onUpCallback = null; }; 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. - * @default - * @property {boolean} disabled + * Add callbacks to the Keyboard handler so that each time a key is pressed down or releases the callbacks are activated. + * @method Phaser.Keyboard#addCallbacks + * @param {Object} context - The context under which the callbacks are run. + * @param {function} onDown - This callback is invoked every time a key is pressed down. + * @param {function} [onUp=null] - This callback is invoked every time a key is released. */ - 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; @@ -90,6 +96,14 @@ Phaser.Keyboard.prototype = { }, + /** + * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. + * The Key object can then be polled, have events attached to it, etc. + * + * @method Phaser.Keyboard#addKey + * @param {number} keycode - The keycode of the key, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @return {Phaser.Key} The Key object which you can store locally and reference directly. + */ addKey: function (keycode) { this._hotkeys[keycode] = new Phaser.Key(this.game, keycode); @@ -97,16 +111,24 @@ Phaser.Keyboard.prototype = { }, + /** + * Removes a Key object from the Keyboard manager. + * + * @method Phaser.Keyboard#removeKey + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + */ removeKey: function (keycode) { delete (this._hotkeys[keycode]); }, - /** - * Description. - * @method start - */ + /** + * Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body. + * This is called automatically by Phaser.Input and should not normally be invoked directly. + * + * @method Phaser.Keyboard#start + */ start: function () { var _this = this; @@ -124,10 +146,11 @@ Phaser.Keyboard.prototype = { }, - /** - * Description. - * @method stop - */ + /** + * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the document.body. + * + * @method Phaser.Keyboard#stop + */ stop: function () { document.body.removeEventListener('keydown', this._onKeyDown); @@ -140,7 +163,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 + * @method Phaser.Keyboard#addKeyCapture * @param {Any} keycode */ addKeyCapture: function (keycode) { @@ -159,8 +182,8 @@ Phaser.Keyboard.prototype = { }, /** - * Description. - * @method removeKeyCapture + * Removes an existing key capture. + * @method Phaser.Keyboard#removeKeyCapture * @param {number} keycode */ removeKeyCapture: function (keycode) { @@ -170,8 +193,8 @@ Phaser.Keyboard.prototype = { }, /** - * Description. - * @method clearCaptures + * Clear all set key captures. + * @method Phaser.Keyboard#clearCaptures */ clearCaptures: function () { @@ -180,9 +203,10 @@ Phaser.Keyboard.prototype = { }, /** - * Description. - * @method processKeyDown + * Process the keydown event. + * @method Phaser.Keyboard#processKeyDown * @param {KeyboardEvent} event + * @protected */ processKeyDown: function (event) { @@ -235,9 +259,10 @@ Phaser.Keyboard.prototype = { }, /** - * Description. - * @method processKeyUp + * Process the keyup event. + * @method Phaser.Keyboard#processKeyUp * @param {KeyboardEvent} event + * @protected */ processKeyUp: function (event) { @@ -267,8 +292,8 @@ Phaser.Keyboard.prototype = { }, /** - * Description. - * @method reset + * Reset the "isDown" state of all keys. + * @method Phaser.Keyboard#reset */ reset: function () { @@ -279,12 +304,12 @@ Phaser.Keyboard.prototype = { }, - /** - * Description. - * @method justPressed - * @param {number} keycode - * @param {number} [duration] - * @return {boolean} + /** + * Returns the "just pressed" state of the key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) + * @method Phaser.Keyboard#justPressed + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @param {number} [duration=250] - The duration below which the key is considered as being just pressed. + * @return {boolean} True if the key is just pressed otherwise false. */ justPressed: function (keycode, duration) { @@ -300,11 +325,11 @@ Phaser.Keyboard.prototype = { }, /** - * Description. - * @method justReleased - * @param {number} keycode - * @param {number} [duration] - * @return {boolean} + * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) + * @method Phaser.Keyboard#justPressed + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @param {number} [duration=250] - The duration below which the key is considered as being just released. + * @return {boolean} True if the key is just released otherwise false. */ justReleased: function (keycode, duration) { @@ -320,10 +345,10 @@ Phaser.Keyboard.prototype = { }, /** - * Description. - * @method isDown - * @param {number} keycode - * @return {boolean} + * Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser. + * @method Phaser.Keyboard#isDown + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @return {boolean} True if the key is currently down. */ isDown: function (keycode) { @@ -338,8 +363,6 @@ Phaser.Keyboard.prototype = { }; -// Statics - Phaser.Keyboard.A = "A".charCodeAt(0); Phaser.Keyboard.B = "B".charCodeAt(0); Phaser.Keyboard.C = "C".charCodeAt(0);