mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Collision fixes for testing
This commit is contained in:
parent
257cbe3be8
commit
51049128f5
6 changed files with 139 additions and 3 deletions
74
Docs/jsdoc_work.txt
Normal file
74
Docs/jsdoc_work.txt
Normal file
|
@ -0,0 +1,74 @@
|
|||
JSDOC3 Work:
|
||||
|
||||
1) This should go at the top of every file (with the module name corrected)
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser.Animation
|
||||
*/
|
||||
|
||||
2) This is the format a constructor should be:
|
||||
|
||||
/**
|
||||
* The constructor description goes here. If there isn't one for you to paste in, just put TODO.
|
||||
*
|
||||
* @class Phaser.Animation
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Phaser.Sprite} parent - A reference to the owner of this Animation.
|
||||
* @param {string} name - The unique name for this animation, used in playback commands.
|
||||
* @param {Phaser.Animation.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
|
||||
* @param {(Array.<number>|Array.<string>)} frames - An array of numbers or strings indicating which frames to play in which order.
|
||||
* @param {number} delay - The time between each frame of the animation, given in ms.
|
||||
* @param {boolean} looped - Should this animation loop or play through once.
|
||||
*/
|
||||
|
||||
You must ensure the class is correct and it has the @constructor tag.
|
||||
It is important you include the data-type. I don't expect you to know what the data type is, so just include: {todo}
|
||||
It is important you include the hypen after the parameter name. You will always know what the parameter name is, so it should always be included.
|
||||
You often won't know what the parameter description is, so just put "todo", like this:
|
||||
|
||||
* @param {todo} name - todo.
|
||||
|
||||
3) Functions are nearly exactly the same as the constructor:
|
||||
|
||||
/**
|
||||
* The function description goes here. If there isn't one for you to paste in, just put TODO.
|
||||
*
|
||||
* @method play
|
||||
* @param {Number} [frameRate=null] The framerate to play the animation at.
|
||||
* @return {Phaser.Animation} A reference to this Animation instance.
|
||||
*/
|
||||
|
||||
You must ensure the @method tag is correct and present.
|
||||
It is important you include the data-type. I don't expect you to know what the data type is, so just include: {todo}
|
||||
It is important you include the hypen after the parameter name. You will always know what the parameter name is, so it should always be included.
|
||||
You often won't know what the parameter description is, so just put "todo", like this:
|
||||
|
||||
* @param {todo} name - todo.
|
||||
|
||||
4) All properties must be marked-up:
|
||||
|
||||
/**
|
||||
* @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback.
|
||||
* @default
|
||||
*/
|
||||
this.isFinished = false;
|
||||
|
||||
It is important you include the data-type. I don't expect you to know what the data type is, so just include: {todo}
|
||||
It is important you include the hypen after the parameter name. You will always know what the parameter name is, so it should always be included.
|
||||
You often won't know what the parameter description is, so just put "todo", like this:
|
||||
|
||||
* @property {todo} isFinished - todo.
|
||||
|
||||
If the property has a base value assigned to it (i.e. a number or a string) then put @default.
|
||||
If the property starts with an underscore it must include @private. Here is an example combining the two:
|
||||
|
||||
/**
|
||||
* @property {number} _frameIndex - The index of the current frame.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._frameIndex = 0;
|
|
@ -51,7 +51,8 @@ Version 1.0.6 (in progress)
|
|||
* Updated ArcadePhysics.separateX/Y to use new body system - much better results now.
|
||||
* QuadTree bug found in 1.0.5 now fixed. The QuadTree is updated properly now using worldTransform values.
|
||||
* Several new examples added (cameras, tweens, etc)
|
||||
|
||||
* TODO: addMarker hh:mm:ss:ms
|
||||
* TODO: Direction constants
|
||||
|
||||
|
||||
Version 1.0.5 (September 20th 2013)
|
||||
|
|
|
@ -20,7 +20,13 @@ var Phaser = Phaser || {
|
|||
RENDERTEXTURE: 8,
|
||||
TILEMAP: 9,
|
||||
TILEMAPLAYER: 10,
|
||||
EMITTER: 11
|
||||
EMITTER: 11,
|
||||
|
||||
NONE: 0,
|
||||
LEFT: 1,
|
||||
RIGHT: 2,
|
||||
UP: 3,
|
||||
DOWN: 4
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -368,9 +368,13 @@ Phaser.StateManager.prototype = {
|
|||
if (this._created == false && this.onCreateCallback)
|
||||
{
|
||||
// console.log('Create callback found');
|
||||
this._created = true;
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
this._created = true;
|
||||
else
|
||||
{
|
||||
this._created = true;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -99,6 +99,9 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
this.prevX = x;
|
||||
this.prevY = y;
|
||||
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
|
||||
|
@ -215,6 +218,9 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
|||
this.renderOrderID = this.game.world.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
|
||||
// |a c tx|
|
||||
// |b d ty|
|
||||
// |0 0 1|
|
||||
|
@ -308,6 +314,22 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
|||
|
||||
}
|
||||
|
||||
Phaser.Sprite.prototype.deltaAbsX = function () {
|
||||
return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX());
|
||||
}
|
||||
|
||||
Phaser.Sprite.prototype.deltaAbsY = function () {
|
||||
return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY());
|
||||
}
|
||||
|
||||
Phaser.Sprite.prototype.deltaX = function () {
|
||||
return this.x - this.prevX;
|
||||
}
|
||||
|
||||
Phaser.Sprite.prototype.deltaY = function () {
|
||||
return this.y - this.prevY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the sprite so its center is located on the given x and y coordinates.
|
||||
* Doesn't change the origin of the sprite.
|
||||
|
|
|
@ -44,6 +44,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|||
this.allowCollision = { none: false, any: true, up: true, down: true, left: true, right: true };
|
||||
this.touching = { none: true, up: false, down: false, left: false, right: false };
|
||||
this.wasTouching = { none: true, up: false, down: false, left: false, right: false };
|
||||
this.facing = Phaser.NONE;
|
||||
|
||||
this.immovable = false;
|
||||
this.moves = true;
|
||||
|
@ -130,6 +131,34 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
|
||||
postUpdate: function () {
|
||||
|
||||
// Calculate forward-facing edge
|
||||
if (this.deltaX() == 0 && this.deltaY() == 0)
|
||||
{
|
||||
// Can't work it out from the Body, how about from x position?
|
||||
if (this.sprite.deltaX() == 0 && this.sprite.deltaY() == 0)
|
||||
{
|
||||
// still as a statue
|
||||
}
|
||||
}
|
||||
|
||||
if (this.deltaX() < 0)
|
||||
{
|
||||
this.facing = Phaser.LEFT;
|
||||
}
|
||||
else if (this.deltaX() > 0)
|
||||
{
|
||||
this.facing = Phaser.RIGHT;
|
||||
}
|
||||
|
||||
if (this.deltaY() < 0)
|
||||
{
|
||||
this.facing = Phaser.UP;
|
||||
}
|
||||
else if (this.deltaY() > 0)
|
||||
{
|
||||
this.facing = Phaser.DOWN;
|
||||
}
|
||||
|
||||
if (this.deltaX() != 0)
|
||||
{
|
||||
this.sprite.x += this.deltaX();
|
||||
|
|
Loading…
Reference in a new issue