mirror of
https://github.com/wassname/phaser.git
synced 2026-07-27 11:25:30 +08:00
Updated documentation.
This commit is contained in:
+104
-77
@@ -54,6 +54,10 @@
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
@@ -138,6 +142,10 @@
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
@@ -302,6 +310,26 @@
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
@@ -310,6 +338,10 @@
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
@@ -356,6 +388,14 @@
|
||||
<a href="global.html#HEXtoRGB">HEXtoRGB</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#render">render</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#renderXY">renderXY</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#right">right</a>
|
||||
</li>
|
||||
@@ -388,32 +428,32 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor for Phaser Input.
|
||||
* Phaser.Input is the Input Manager for all types of Input across Phaser, including mouse, keyboard, touch and MSPointer.
|
||||
* The Input manager is updated automatically by the core game loop.
|
||||
*
|
||||
* @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 {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Description} hitCanvas - Description.
|
||||
/**
|
||||
* @property {HTMLCanvasElement} hitCanvas - The canvas to which single pixels are drawn in order to perform pixel-perfect hit detection.
|
||||
* @default
|
||||
*/
|
||||
*/
|
||||
this.hitCanvas = null;
|
||||
|
||||
/**
|
||||
* @property {Description} hitContext - Description.
|
||||
* @default
|
||||
*/
|
||||
/**
|
||||
* @property {CanvasRenderingContext2D} hitContext - The context of the pixel perfect hit canvas.
|
||||
* @default
|
||||
*/
|
||||
this.hitContext = null;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -436,11 +476,6 @@ 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.
|
||||
@@ -450,31 +485,28 @@ Phaser.Input.prototype = {
|
||||
pollRate: 0,
|
||||
|
||||
/**
|
||||
* @property {number} _pollCounter - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
* @property {number} _pollCounter - Internal var holding the current poll counter.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
_pollCounter: 0,
|
||||
|
||||
/**
|
||||
* A vector object representing the previous position of the Pointer.
|
||||
* @property {Vec2} vector
|
||||
* @property {Phaser.Point} _oldPosition - A point object representing the previous position of the Pointer.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
_oldPosition: null,
|
||||
|
||||
/**
|
||||
* X coordinate of the most recent Pointer event
|
||||
* @property {number} _x
|
||||
* @property {number} _x - x coordinate of the most recent Pointer event
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
_x: 0,
|
||||
|
||||
/**
|
||||
* Y coordinate of the most recent Pointer event
|
||||
* @property {number} _y
|
||||
* @property {number} _y - Y coordinate of the most recent Pointer event
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
@@ -495,17 +527,14 @@ Phaser.Input.prototype = {
|
||||
multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE,
|
||||
|
||||
/**
|
||||
* A vector object representing the current position of the Pointer.
|
||||
* @property {Phaser.Point} position
|
||||
* @property {Phaser.Point} position - A point object representing the current position of the Pointer.
|
||||
* @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.
|
||||
* A point object representing the speed of the Pointer. Only really useful in single Pointer games, otherwise see the Pointer objects directly.
|
||||
* @property {Phaser.Point} speed
|
||||
* @default
|
||||
*/
|
||||
speed: null,
|
||||
|
||||
@@ -513,7 +542,6 @@ Phaser.Input.prototype = {
|
||||
* 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 {Phaser.Circle} circle
|
||||
* @default
|
||||
*/
|
||||
circle: null,
|
||||
|
||||
@@ -521,7 +549,6 @@ Phaser.Input.prototype = {
|
||||
* 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 {Phaser.Point} scale
|
||||
* @default
|
||||
*/
|
||||
scale: null,
|
||||
|
||||
@@ -650,7 +677,7 @@ Phaser.Input.prototype = {
|
||||
/**
|
||||
* A Pointer object
|
||||
* @property {Phaser.Pointer} pointer9
|
||||
*/
|
||||
*/
|
||||
pointer9: null,
|
||||
|
||||
/**
|
||||
@@ -736,40 +763,40 @@ Phaser.Input.prototype = {
|
||||
*/
|
||||
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.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.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.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.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.circle = new Phaser.Circle(0, 0, 44);
|
||||
|
||||
this.activePointer = this.mousePointer;
|
||||
this.currentPointers = 0;
|
||||
this.activePointer = this.mousePointer;
|
||||
this.currentPointers = 0;
|
||||
|
||||
this.hitCanvas = document.createElement('canvas');
|
||||
this.hitCanvas.width = 1;
|
||||
this.hitCanvas.height = 1;
|
||||
this.hitCanvas = document.createElement('canvas');
|
||||
this.hitCanvas.width = 1;
|
||||
this.hitCanvas.height = 1;
|
||||
this.hitContext = this.hitCanvas.getContext('2d');
|
||||
|
||||
this.mouse.start();
|
||||
@@ -793,7 +820,7 @@ Phaser.Input.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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
|
||||
@@ -811,7 +838,7 @@ Phaser.Input.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
if (next == 0)
|
||||
if (next === 0)
|
||||
{
|
||||
console.warn("You can only have 10 Pointer objects");
|
||||
return null;
|
||||
@@ -824,7 +851,7 @@ Phaser.Input.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Updates the Input Manager. Called by the core Game loop.
|
||||
* @method Phaser.Input#update
|
||||
* @protected
|
||||
@@ -858,14 +885,14 @@ Phaser.Input.prototype = {
|
||||
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)
|
||||
if (this.game.isBooted === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -886,7 +913,7 @@ Phaser.Input.prototype = {
|
||||
this.currentPointers = 0;
|
||||
this.game.stage.canvas.style.cursor = "default";
|
||||
|
||||
if (hard == true)
|
||||
if (hard === true)
|
||||
{
|
||||
this.onDown.dispose();
|
||||
this.onUp.dispose();
|
||||
@@ -917,7 +944,7 @@ Phaser.Input.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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.
|
||||
@@ -930,11 +957,11 @@ Phaser.Input.prototype = {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.pointer1.active == false)
|
||||
if (this.pointer1.active === false)
|
||||
{
|
||||
return this.pointer1.start(event);
|
||||
}
|
||||
else if (this.pointer2.active == false)
|
||||
else if (this.pointer2.active === false)
|
||||
{
|
||||
return this.pointer2.start(event);
|
||||
}
|
||||
@@ -942,7 +969,7 @@ Phaser.Input.prototype = {
|
||||
{
|
||||
for (var i = 3; i <= 10; i++)
|
||||
{
|
||||
if (this['pointer' + i] && this['pointer' + i].active == false)
|
||||
if (this['pointer' + i] && this['pointer' + i].active === false)
|
||||
{
|
||||
return this['pointer' + i].start(event);
|
||||
}
|
||||
@@ -953,7 +980,7 @@ Phaser.Input.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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.
|
||||
@@ -984,7 +1011,7 @@ Phaser.Input.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Stops the matching Pointer object, passing in the event data.
|
||||
* @method Phaser.Input#stopPointer
|
||||
* @param {Any} event - The event data from the Touch event.
|
||||
@@ -1015,7 +1042,7 @@ Phaser.Input.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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).
|
||||
@@ -1048,7 +1075,7 @@ Phaser.Input.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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.
|
||||
@@ -1176,7 +1203,7 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
|
||||
Object.defineProperty(Phaser.Input.prototype, "worldX", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.view.x + this.x;
|
||||
return this.game.camera.view.x + this.x;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1189,7 +1216,7 @@ Object.defineProperty(Phaser.Input.prototype, "worldX", {
|
||||
Object.defineProperty(Phaser.Input.prototype, "worldY", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.view.y + this.y;
|
||||
return this.game.camera.view.y + this.y;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1214,7 +1241,7 @@ Object.defineProperty(Phaser.Input.prototype, "worldY", {
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
on Thu Nov 28 2013 15:56:25 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user