mirror of
https://github.com/wassname/phaser.git
synced 2026-07-18 12:30:44 +08:00
* Fixed issue 135 - Added typeof checks into most ArcadePhysics functions to avoid errors with zero values.
* Fixed issue 136 - distanceTo using worldX/Y instead of x/y.
This commit is contained in:
@@ -39,6 +39,9 @@ Change Log
|
||||
|
||||
Version 1.1.2
|
||||
|
||||
* Fixed issue 135 - Added typeof checks into most ArcadePhysics functions to avoid errors with zero values.
|
||||
* Fixed issue 136 - distanceTo using worldX/Y instead of x/y.
|
||||
|
||||
|
||||
|
||||
Version 1.1.1 - October 26th 2013
|
||||
|
||||
@@ -44,6 +44,9 @@ function create() {
|
||||
|
||||
sprite = game.add.sprite(400, 550, 'phaser');
|
||||
|
||||
// Stop the following keys from propagating up to the browser
|
||||
game.input.keyboard.addKeyCapture([ Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT, Phaser.Keyboard.SPACEBAR ]);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
@@ -37,6 +37,8 @@ function create() {
|
||||
c.body.immovable = true;
|
||||
}
|
||||
|
||||
game.input.keyboard.addKeyCapture([ Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT, Phaser.Keyboard.UP, Phaser.Keyboard.DOWN ]);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
@@ -52,7 +52,7 @@ function test2 () {
|
||||
sprite1.body.immovable = true;
|
||||
// sprite1.body.setSize(100, 100, 0, 0);
|
||||
|
||||
sprite2 = game.add.sprite(-100, 150, 'mushroom');
|
||||
sprite2 = game.add.sprite(-100, 140, 'mushroom');
|
||||
sprite2.name = 'mushroom';
|
||||
|
||||
sprite3 = game.add.sprite(-200, 150, 'flectrum');
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
<div class="header">
|
||||
<div class="box100 no-padding">
|
||||
<div class="phaser-version">
|
||||
<span>Phaser Version: 1.1</span>
|
||||
<span>Phaser Version: 1.1.2</span>
|
||||
<a id="upgrade" href="https://github.com/photonstorm/phaser" class="version-button">New version: </a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</div>
|
||||
<div id="footer">
|
||||
<p id="total">Total examples: </p>
|
||||
<p>Phaser version: 1.1</p>
|
||||
<p>Phaser version: 1.1.2</p>
|
||||
<p><a href="index.html">Switch to Full View</a></p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
@@ -54,7 +54,7 @@ function create() {
|
||||
sprite.anchor.setTo(0.5, 0.5);
|
||||
|
||||
game.camera.follow(sprite);
|
||||
game.camera.deadzone = new Phaser.Rectangle(160, 160, layer.renderWidth-320, layer.renderHeight-320);
|
||||
// game.camera.deadzone = new Phaser.Rectangle(160, 160, layer.renderWidth-320, layer.renderHeight-320);
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
@@ -80,7 +80,7 @@ function particleBurst() {
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(sprite, layer);
|
||||
// game.physics.collide(sprite, layer);
|
||||
game.physics.collide(emitter, layer);
|
||||
|
||||
sprite.body.velocity.x = 0;
|
||||
@@ -88,7 +88,7 @@ function update() {
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
sprite.body.velocity.y = -150;
|
||||
sprite.body.velocity.y = -150;
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
@@ -107,3 +107,12 @@ function update() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function render() {
|
||||
|
||||
// game.debug.renderSpriteCorners(sprite);
|
||||
// game.debug.renderSpriteInfo(sprite, 32, 32);
|
||||
game.debug.renderSpriteCoords(sprite, 32, 32);
|
||||
|
||||
}
|
||||
@@ -364,8 +364,16 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
||||
this.renderOrderID = this.game.world.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
if (this.fixedToCamera)
|
||||
{
|
||||
this.prevX = this.game.camera.view.x + this.x;
|
||||
this.prevY = this.game.camera.view.y + this.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.prevX = this.x;
|
||||
this.prevY = this.y;
|
||||
}
|
||||
|
||||
this.updateCache();
|
||||
this.updateAnimation();
|
||||
|
||||
@@ -404,28 +404,25 @@ Phaser.Physics.Arcade.prototype = {
|
||||
|
||||
this._mapData = tilemapLayer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true);
|
||||
|
||||
if (this._mapData.length > 1)
|
||||
// console.log('getTiles', this._tx, this._ty);
|
||||
if (this.game.input.keyboard.isDown(Phaser.Keyboard.SHIFT))
|
||||
{
|
||||
for (var i = 1; i < this._mapData.length; i++)
|
||||
console.log('cst', this._mapData, sprite.body.x, sprite.body.y);
|
||||
}
|
||||
|
||||
if (this._mapData.length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < this._mapData.length; i++)
|
||||
{
|
||||
if (this.separateTile(sprite.body, this._mapData[i]))
|
||||
{
|
||||
this.separateTile(sprite.body, this._mapData[i]);
|
||||
|
||||
if (this._result)
|
||||
// They collided, is there a custom process callback?
|
||||
if (processCallback)
|
||||
{
|
||||
// They collided, is there a custom process callback?
|
||||
if (processCallback)
|
||||
{
|
||||
if (processCallback.call(callbackContext, sprite, this._mapData[i]))
|
||||
{
|
||||
this._total++;
|
||||
|
||||
if (collideCallback)
|
||||
{
|
||||
collideCallback.call(callbackContext, sprite, this._mapData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (processCallback.call(callbackContext, sprite, this._mapData[i]))
|
||||
{
|
||||
this._total++;
|
||||
|
||||
@@ -435,6 +432,15 @@ Phaser.Physics.Arcade.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._total++;
|
||||
|
||||
if (collideCallback)
|
||||
{
|
||||
collideCallback.call(callbackContext, sprite, this._mapData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1025,8 +1031,8 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
moveToObject: function (displayObject, destination, speed, maxTime) {
|
||||
|
||||
speed = speed || 60;
|
||||
maxTime = maxTime || 0;
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
if (typeof maxTime === 'undefined') { maxTime = 0; }
|
||||
|
||||
this._angle = Math.atan2(destination.y - displayObject.y, destination.x - displayObject.x);
|
||||
|
||||
@@ -1059,9 +1065,9 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
moveToPointer: function (displayObject, speed, pointer, maxTime) {
|
||||
|
||||
speed = speed || 60;
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
pointer = pointer || this.game.input.activePointer;
|
||||
maxTime = maxTime || 0;
|
||||
if (typeof maxTime === 'undefined') { maxTime = 0; }
|
||||
|
||||
this._angle = this.angleToPointer(displayObject, pointer);
|
||||
|
||||
@@ -1096,8 +1102,8 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
moveToXY: function (displayObject, x, y, speed, maxTime) {
|
||||
|
||||
speed = speed || 60;
|
||||
maxTime = maxTime || 0;
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
if (typeof maxTime === 'undefined') { maxTime = 0; }
|
||||
|
||||
this._angle = Math.atan2(y - displayObject.y, x - displayObject.x);
|
||||
|
||||
@@ -1126,7 +1132,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
velocityFromAngle: function (angle, speed, point) {
|
||||
|
||||
speed = speed || 60;
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
point = point || new Phaser.Point;
|
||||
|
||||
return point.setTo((Math.cos(this.game.math.degToRad(angle)) * speed), (Math.sin(this.game.math.degToRad(angle)) * speed));
|
||||
@@ -1145,7 +1151,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
velocityFromRotation: function (rotation, speed, point) {
|
||||
|
||||
speed = speed || 60;
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
point = point || new Phaser.Point;
|
||||
|
||||
return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed));
|
||||
@@ -1164,7 +1170,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
accelerationFromRotation: function (rotation, speed, point) {
|
||||
|
||||
speed = speed || 60;
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
point = point || new Phaser.Point;
|
||||
|
||||
return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed));
|
||||
@@ -1311,8 +1317,8 @@ Phaser.Physics.Arcade.prototype = {
|
||||
|
||||
pointer = pointer || this.game.input.activePointer;
|
||||
|
||||
this._dx = displayObject.worldX - pointer.x;
|
||||
this._dy = displayObject.worldY - pointer.y;
|
||||
this._dx = displayObject.x - pointer.x;
|
||||
this._dy = displayObject.y - pointer.y;
|
||||
|
||||
return Math.sqrt(this._dx * this._dx + this._dy * this._dy);
|
||||
|
||||
|
||||
@@ -350,6 +350,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
this.embedded = false;
|
||||
|
||||
|
||||
|
||||
this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
|
||||
this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
|
||||
|
||||
|
||||
@@ -311,10 +311,13 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides
|
||||
this._tw = (this.game.math.snapToCeil(width, tileWidth) + tileWidth) / tileWidth;
|
||||
this._th = (this.game.math.snapToCeil(height, tileHeight) + tileHeight) / tileHeight;
|
||||
|
||||
this._results.length = 0;
|
||||
// This should apply the layer x/y here
|
||||
|
||||
// this._results.length = 0;
|
||||
this._results = [];
|
||||
|
||||
// pretty sure we don't use this any more?
|
||||
this._results.push( { x: x, y: y, width: width, height: height, tx: this._tx, ty: this._ty, tw: this._tw, th: this._th });
|
||||
// this._results.push( { x: x, y: y, width: width, height: height, tx: this._tx, ty: this._ty, tw: this._tw, th: this._th });
|
||||
|
||||
var _index = 0;
|
||||
var _tile = null;
|
||||
|
||||
@@ -559,6 +559,8 @@ Phaser.Utils.Debug.prototype = {
|
||||
this.line(sprite.name);
|
||||
this.line('x: ' + sprite.x);
|
||||
this.line('y: ' + sprite.y);
|
||||
this.line('pos x: ' + sprite.position.x);
|
||||
this.line('pos y: ' + sprite.position.y);
|
||||
this.line('local x: ' + sprite.localTransform[2]);
|
||||
this.line('local y: ' + sprite.localTransform[5]);
|
||||
this.line('world x: ' + sprite.worldTransform[2]);
|
||||
|
||||
Reference in New Issue
Block a user