mirror of
https://github.com/wassname/phaser.git
synced 2026-07-17 01:30:32 +08:00
Updated doc files.
This commit is contained in:
+137
-54
@@ -90,6 +90,10 @@
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
@@ -162,6 +166,14 @@
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
@@ -186,6 +198,10 @@
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
@@ -278,6 +294,10 @@
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
@@ -342,6 +362,10 @@
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
@@ -374,36 +398,6 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#bottom">bottom</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<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>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -423,7 +417,7 @@
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
@@ -632,6 +626,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
*/
|
||||
this._cache = {
|
||||
|
||||
fresh: true,
|
||||
dirty: false,
|
||||
|
||||
// Transform cache
|
||||
@@ -777,7 +772,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
/**
|
||||
* @property {Phaser.Point} cameraOffset - If this Sprite is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
|
||||
*/
|
||||
this.cameraOffset = new Phaser.Point();
|
||||
this.cameraOffset = new Phaser.Point(x, y);
|
||||
|
||||
/**
|
||||
* You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide.
|
||||
@@ -793,9 +788,19 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
*/
|
||||
this.cropEnabled = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} debug - Handy flag to use with Game.enableStep
|
||||
* @default
|
||||
*/
|
||||
this.debug = false;
|
||||
|
||||
this.updateCache();
|
||||
this.updateBounds();
|
||||
|
||||
/**
|
||||
* @property {PIXI.Point} pivot - The pivot point of the displayObject that it rotates around.
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
// Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly)
|
||||
@@ -810,6 +815,24 @@ Phaser.Sprite.prototype.constructor = Phaser.Sprite;
|
||||
*/
|
||||
Phaser.Sprite.prototype.preUpdate = function() {
|
||||
|
||||
if (this._cache.fresh)
|
||||
{
|
||||
this.world.setTo(this.parent.position.x + this.x, this.parent.position.y + this.y);
|
||||
this.worldTransform[2] = this.world.x;
|
||||
this.worldTransform[5] = this.world.y;
|
||||
this._cache.fresh = false;
|
||||
|
||||
if (this.body)
|
||||
{
|
||||
this.body.x = (this.world.x - (this.anchor.x * this.width)) + this.body.offset.x;
|
||||
this.body.y = (this.world.y - (this.anchor.y * this.height)) + this.body.offset.y;
|
||||
this.body.preX = this.body.x;
|
||||
this.body.preY = this.body.y;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.exists || (this.group && !this.group.exists))
|
||||
{
|
||||
this.renderOrderID = -1;
|
||||
@@ -925,7 +948,6 @@ Phaser.Sprite.prototype.updateAnimation = function() {
|
||||
this._cache.halfHeight = Math.floor(this._cache.height / 2);
|
||||
|
||||
this._cache.dirty = true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1020,12 +1042,6 @@ Phaser.Sprite.prototype.updateBounds = function() {
|
||||
this.renderable = this._cache.cameraVisible;
|
||||
}
|
||||
|
||||
// Update our physics bounds
|
||||
if (this.body)
|
||||
{
|
||||
this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1036,9 +1052,7 @@ Phaser.Sprite.prototype.updateBounds = function() {
|
||||
* @memberof Phaser.Sprite
|
||||
* @param {Phaser.Point} p - The Point object to store the results in.
|
||||
* @param {number} x - x coordinate within the Sprite to translate.
|
||||
* @param {number} y - x coordinate within the Sprite to translate.
|
||||
* @param {number} sx - Scale factor to be applied.
|
||||
* @param {number} sy - Scale factor to be applied.
|
||||
* @param {number} y - y coordinate within the Sprite to translate.
|
||||
* @return {Phaser.Point} The translated point.
|
||||
*/
|
||||
Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
|
||||
@@ -1057,8 +1071,8 @@ Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
|
||||
* @method Phaser.Sprite#getLocalUnmodifiedPosition
|
||||
* @memberof Phaser.Sprite
|
||||
* @param {Phaser.Point} p - The Point object to store the results in.
|
||||
* @param {number} x - x coordinate within the Sprite to translate.
|
||||
* @param {number} y - x coordinate within the Sprite to translate.
|
||||
* @param {number} gx - x coordinate within the Sprite to translate.
|
||||
* @param {number} gy - y coordinate within the Sprite to translate.
|
||||
* @return {Phaser.Point} The translated point.
|
||||
*/
|
||||
Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, gx, gy) {
|
||||
@@ -1099,7 +1113,6 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
||||
|
||||
if (this.exists)
|
||||
{
|
||||
// The sprite is positioned in this call, after taking into consideration motion updates and collision
|
||||
if (this.body)
|
||||
{
|
||||
this.body.postUpdate();
|
||||
@@ -1116,8 +1129,6 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
||||
this._cache.y = this.y;
|
||||
}
|
||||
|
||||
this.world.setTo(this.game.camera.x + this.worldTransform[2], this.game.camera.y + this.worldTransform[5]);
|
||||
|
||||
this.position.x = this._cache.x;
|
||||
this.position.y = this._cache.y;
|
||||
}
|
||||
@@ -1195,8 +1206,17 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame) {
|
||||
*/
|
||||
Phaser.Sprite.prototype.centerOn = function(x, y) {
|
||||
|
||||
this.x = x + (this.x - this.center.x);
|
||||
this.y = y + (this.y - this.center.y);
|
||||
if (this.fixedToCamera)
|
||||
{
|
||||
this.cameraOffset.x = x + (this.cameraOffset.x - this.center.x);
|
||||
this.cameraOffset.y = y + (this.cameraOffset.y - this.center.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.x = x + (this.x - this.center.x);
|
||||
this.y = y + (this.y - this.center.y);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
@@ -1263,6 +1283,11 @@ Phaser.Sprite.prototype.kill = function() {
|
||||
*/
|
||||
Phaser.Sprite.prototype.destroy = function() {
|
||||
|
||||
if (this.filters)
|
||||
{
|
||||
this.filters = null;
|
||||
}
|
||||
|
||||
if (this.group)
|
||||
{
|
||||
this.group.remove(this);
|
||||
@@ -1283,6 +1308,11 @@ Phaser.Sprite.prototype.destroy = function() {
|
||||
this.animations.destroy();
|
||||
}
|
||||
|
||||
if (this.body)
|
||||
{
|
||||
this.body.destroy();
|
||||
}
|
||||
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
this.visible = false;
|
||||
@@ -1334,6 +1364,7 @@ Phaser.Sprite.prototype.reset = function(x, y, health) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.world.setTo(x, y);
|
||||
this.position.x = this.x;
|
||||
this.position.y = this.y;
|
||||
this.alive = true;
|
||||
@@ -1346,7 +1377,7 @@ Phaser.Sprite.prototype.reset = function(x, y, health) {
|
||||
|
||||
if (this.body)
|
||||
{
|
||||
this.body.reset();
|
||||
this.body.reset(false);
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -1397,6 +1428,34 @@ Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete)
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the delta x value. The difference between Sprite.x now and in the previous step.
|
||||
* @name Phaser.Sprite#deltaX
|
||||
* @property {number} deltaX - The delta value. Positive if the motion was to the right, negative if to the left.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, 'deltaX', {
|
||||
|
||||
get: function() {
|
||||
return this.world.x - this._cache.prevX;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns the delta x value. The difference between Sprite.y now and in the previous step.
|
||||
* @name Phaser.Sprite#deltaY
|
||||
* @property {number} deltaY - The delta value. Positive if the motion was downwards, negative if upwards.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, 'deltaY', {
|
||||
|
||||
get: function() {
|
||||
return this.world.y - this._cache.prevY;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
||||
* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
|
||||
@@ -1461,6 +1520,32 @@ Object.defineProperty(Phaser.Sprite.prototype, "inCamera", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Sprite#worldCenterX
|
||||
* @property {number} worldCenterX - The center of the Sprite in world coordinates.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "worldCenterX", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.x + this.center.x;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Sprite#worldCenterY
|
||||
* @property {number} worldCenterY - The center of the Sprite in world coordinates.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "worldCenterY", {
|
||||
|
||||
get: function () {
|
||||
return this.game.camera.y + this.center.y;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The width of the sprite in pixels, setting this will actually modify the scale to acheive the value desired.
|
||||
* If you wish to crop the Sprite instead see the Sprite.crop value.
|
||||
@@ -1524,8 +1609,6 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
|
||||
|
||||
set: function (value) {
|
||||
|
||||
console.log('inputEnabled', value, this.input);
|
||||
|
||||
if (value)
|
||||
{
|
||||
if (this.input.enabled === false)
|
||||
@@ -1559,13 +1642,13 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2013 Photon Storm Ltd.
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Thu Nov 28 2013 15:56:25 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
on Wed Feb 05 2014 06:28:24 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