Skip to content

Commit 6cc0a48

Browse files
committed
Phaser 2.4.7 RC2.
1 parent b441ee3 commit 6cc0a48

18 files changed

Lines changed: 404 additions & 343 deletions

build/custom/phaser-arcade-physics.js

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Phaser - http://phaser.io
99
*
10-
* v2.4.7 "Hinderstap" - Built: Thu Apr 14 2016 13:21:31
10+
* v2.4.7 "Hinderstap" - Built: Fri Apr 22 2016 14:44:10
1111
*
1212
* By Richard Davey http://www.photonstorm.com @photonstorm
1313
*
@@ -1866,16 +1866,19 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
18661866
var dx = (this.texture.trim) ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width;
18671867
var dy = (this.texture.trim) ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
18681868

1869+
var tx = (wt.tx * renderSession.resolution) + renderSession.shakeX;
1870+
var ty = (wt.ty * renderSession.resolution) + renderSession.shakeY;
1871+
18691872
// Allow for pixel rounding
18701873
if (renderSession.roundPixels)
18711874
{
1872-
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, (wt.tx * renderSession.resolution) | 0, (wt.ty * renderSession.resolution) | 0);
1875+
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx | 0, ty | 0);
18731876
dx |= 0;
18741877
dy |= 0;
18751878
}
18761879
else
18771880
{
1878-
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderSession.resolution, wt.ty * renderSession.resolution);
1881+
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx, ty);
18791882
}
18801883

18811884
var cw = this.texture.crop.width;
@@ -2094,8 +2097,8 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
20942097
frame.y,
20952098
frame.width,
20962099
frame.height,
2097-
((child.anchor.x) * (-frame.width * child.scale.x) + child.position.x + 0.5) | 0,
2098-
((child.anchor.y) * (-frame.height * child.scale.y) + child.position.y + 0.5) | 0,
2100+
((child.anchor.x) * (-frame.width * child.scale.x) + child.position.x + 0.5 + renderSession.shakeX) | 0,
2101+
((child.anchor.y) * (-frame.height * child.scale.y) + child.position.y + 0.5 + renderSession.shakeY) | 0,
20992102
frame.width * child.scale.x,
21002103
frame.height * child.scale.y);
21012104
}
@@ -2106,16 +2109,18 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
21062109
child.displayObjectUpdateTransform();
21072110

21082111
var childTransform = child.worldTransform;
2112+
var tx = (childTransform.tx * renderSession.resolution) + renderSession.shakeX;
2113+
var ty = (childTransform.ty * renderSession.resolution) + renderSession.shakeY;
21092114

21102115
// allow for trimming
21112116

21122117
if (renderSession.roundPixels)
21132118
{
2114-
context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx | 0, childTransform.ty | 0);
2119+
context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, tx | 0, ty | 0);
21152120
}
21162121
else
21172122
{
2118-
context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx, childTransform.ty);
2123+
context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, tx, ty);
21192124
}
21202125

21212126
context.drawImage(texture.baseTexture.source,
@@ -3687,6 +3692,9 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
36873692
gl.clear(gl.COLOR_BUFFER_BIT);
36883693
}
36893694

3695+
this.offset.x = this.game.camera._shake.x;
3696+
this.offset.y = this.game.camera._shake.y;
3697+
36903698
this.renderDisplayObject(stage, this.projection);
36913699
};
36923700

@@ -6655,6 +6663,9 @@ PIXI.CanvasRenderer.prototype.render = function (stage) {
66556663
this.context.globalAlpha = 1;
66566664

66576665
this.renderSession.currentBlendMode = 0;
6666+
this.renderSession.shakeX = this.game.camera._shake.x;
6667+
this.renderSession.shakeY = this.game.camera._shake.y;
6668+
66586669
this.context.globalCompositeOperation = 'source-over';
66596670

66606671
if (navigator.isCocoonJS && this.view.screencanvas)
@@ -8114,13 +8125,16 @@ PIXI.Strip.prototype._renderCanvas = function(renderSession)
81148125

81158126
var transform = this.worldTransform;
81168127

8128+
var tx = (transform.tx * renderSession.resolution) + renderSession.shakeX;
8129+
var ty = (transform.ty * renderSession.resolution) + renderSession.shakeY;
8130+
81178131
if (renderSession.roundPixels)
81188132
{
8119-
context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx | 0, transform.ty | 0);
8133+
context.setTransform(transform.a, transform.b, transform.c, transform.d, tx | 0, ty | 0);
81208134
}
81218135
else
81228136
{
8123-
context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty);
8137+
context.setTransform(transform.a, transform.b, transform.c, transform.d, tx, ty);
81248138
}
81258139

81268140
if (this.drawMode === PIXI.Strip.DrawModes.TRIANGLE_STRIP)
@@ -8784,8 +8798,10 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
87848798

87858799
var wt = this.worldTransform;
87868800
var resolution = renderSession.resolution;
8801+
var tx = (wt.tx * resolution) + renderSession.shakeX;
8802+
var ty = (wt.ty * resolution) + renderSession.shakeY;
87878803

8788-
context.setTransform(wt.a * resolution, wt.b * resolution, wt.c * resolution, wt.d * resolution, wt.tx * resolution, wt.ty * resolution);
8804+
context.setTransform(wt.a * resolution, wt.b * resolution, wt.c * resolution, wt.d * resolution, tx, ty);
87898805

87908806
if (this.refreshTexture)
87918807
{
@@ -9138,7 +9154,7 @@ var Phaser = Phaser || {
91389154
* @constant
91399155
* @type {string}
91409156
*/
9141-
VERSION: '2.4.7 RC1',
9157+
VERSION: '2.4.7 RC2',
91429158

91439159
/**
91449160
* An array of Phaser game instances.
@@ -14829,8 +14845,10 @@ Phaser.Camera.prototype = {
1482914845
this._shake.y = Math.floor(this._shake.y);
1483014846
}
1483114847

14832-
this.displayObject.position.x = -(this.view.x + this._shake.x);
14833-
this.displayObject.position.y = -(this.view.y + this._shake.y);
14848+
// this.displayObject.position.x = -(this.view.x + this._shake.x);
14849+
// this.displayObject.position.y = -(this.view.y + this._shake.y);
14850+
this.displayObject.position.x = -this.view.x;
14851+
this.displayObject.position.y = -this.view.y;
1483414852

1483514853
},
1483614854

@@ -17775,7 +17793,7 @@ Phaser.Stage.prototype.update = function () {
1777517793

1777617794
/**
1777717795
* This is called automatically before the renderer runs and after the plugins have updated.
17778-
* In postUpdate this is where all the final physics calculatations and object positioning happens.
17796+
* In postUpdate this is where all the final physics calculations and object positioning happens.
1777917797
* The objects are processed in the order of the display list.
1778017798
* The only exception to this is if the camera is following an object, in which case that is updated first.
1778117799
*
@@ -17960,7 +17978,7 @@ Phaser.Stage.prototype.setBackgroundColor = function (color) {
1796017978
*
1796117979
* @method Phaser.Stage#destroy
1796217980
*/
17963-
Phaser.Stage.prototype.destroy = function () {
17981+
Phaser.Stage.prototype.destroy = function () {
1796417982

1796517983
if (this._hiddenVar)
1796617984
{
@@ -19461,7 +19479,6 @@ Phaser.Group.prototype.postUpdate = function () {
1946119479

1946219480
};
1946319481

19464-
1946519482
/**
1946619483
* Find children matching a certain predicate.
1946719484
*
@@ -26433,6 +26450,8 @@ Phaser.InputHandler = function (sprite) {
2643326450
id: 0,
2643426451
x: 0,
2643526452
y: 0,
26453+
camX: 0,
26454+
camY: 0,
2643626455
isDown: false,
2643726456
isUp: false,
2643826457
isOver: false,
@@ -27301,14 +27320,17 @@ Phaser.InputHandler.prototype = {
2730127320
}
2730227321
else
2730327322
{
27323+
var cx = this.game.camera.x - this._pointerData[pointer.id].camX;
27324+
var cy = this.game.camera.y - this._pointerData[pointer.id].camY;
27325+
2730427326
if (this.allowHorizontalDrag)
2730527327
{
27306-
this.sprite.x = px;
27328+
this.sprite.x = px + cx;
2730727329
}
2730827330

2730927331
if (this.allowVerticalDrag)
2731027332
{
27311-
this.sprite.y = py;
27333+
this.sprite.y = py + cy;
2731227334
}
2731327335

2731427336
if (this.boundsRect)
@@ -27526,6 +27548,10 @@ Phaser.InputHandler.prototype = {
2752627548

2752727549
this.isDragged = true;
2752827550
this._draggedPointerID = pointer.id;
27551+
27552+
this._pointerData[pointer.id].camX = this.game.camera.x;
27553+
this._pointerData[pointer.id].camY = this.game.camera.y;
27554+
2752927555
this._pointerData[pointer.id].isDragged = true;
2753027556

2753127557
if (this.sprite.fixedToCamera)
@@ -37749,13 +37775,15 @@ PIXI.Graphics.prototype._renderCanvas = function(renderSession)
3774937775
}
3775037776

3775137777
var resolution = renderSession.resolution;
37778+
var tx = (transform.tx * renderSession.resolution) + renderSession.shakeX;
37779+
var ty = (transform.ty * renderSession.resolution) + renderSession.shakeY;
3775237780

3775337781
context.setTransform(transform.a * resolution,
3775437782
transform.b * resolution,
3775537783
transform.c * resolution,
3775637784
transform.d * resolution,
37757-
transform.tx * resolution,
37758-
transform.ty * resolution);
37785+
tx,
37786+
ty);
3775937787

3776037788
PIXI.CanvasGraphics.renderGraphics(this, context);
3776137789

@@ -58652,7 +58680,7 @@ Phaser.Loader.prototype = {
5865258680
{
5865358681
if (file.asBlob)
5865458682
{
58655-
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
58683+
this.xhrLoad(file, this.transformUrl(file.url, file), 'blob', this.fileComplete);
5865658684
}
5865758685
else
5865858686
{
@@ -58813,9 +58841,9 @@ Phaser.Loader.prototype = {
5881358841
var playThroughEvent = function () {
5881458842
file.data.removeEventListener('canplaythrough', playThroughEvent, false);
5881558843
file.data.onerror = null;
58816-
// Why does this cycle through games?
58817-
Phaser.GAMES[_this.game.id].load.fileComplete(file);
58844+
_this.fileComplete(file);
5881858845
};
58846+
5881958847
file.data.onerror = function () {
5882058848
file.data.removeEventListener('canplaythrough', playThroughEvent, false);
5882158849
file.data.onerror = null;
@@ -59239,7 +59267,7 @@ Phaser.Loader.prototype = {
5923959267
{
5924059268
try
5924159269
{
59242-
file.data = new Blob([new Uint8Array(xhr.response)]);
59270+
file.data = xhr.response;
5924359271
}
5924459272
catch (e)
5924559273
{
@@ -66337,7 +66365,7 @@ Phaser.LinkedList.prototype.constructor = Phaser.LinkedList;
6633766365
* quickly and easily, without the need for any external files. You can create textures for sprites and in
6633866366
* coming releases we'll add dynamic sound effect generation support as well (like sfxr).
6633966367
*
66340-
* Access this via `State.create` (or `this.create` from within a State object)
66368+
* Access this via `Game.create` (`this.game.create` from within a State object)
6634166369
*
6634266370
* @class Phaser.Create
6634366371
* @constructor
@@ -69729,59 +69757,35 @@ Phaser.Physics.Arcade.prototype = {
6972969757
* Check for intersection against two bodies.
6973069758
*
6973169759
* @method Phaser.Physics.Arcade#intersects
69732-
* @param {Phaser.Physics.Arcade.Body} body1 - The Body object to check.
69733-
* @param {Phaser.Physics.Arcade.Body} body2 - The Body object to check.
69760+
* @param {Phaser.Physics.Arcade.Body} body1 - The first Body object to check.
69761+
* @param {Phaser.Physics.Arcade.Body} body2 - The second Body object to check.
6973469762
* @return {boolean} True if they intersect, otherwise false.
6973569763
*/
6973669764
intersects: function (body1, body2) {
6973769765

69738-
if (body1.isCircle)
69766+
// Rect vs. Rect
69767+
if (body1.right <= body2.position.x)
6973969768
{
69740-
if (body2.isCircle)
69741-
{
69742-
// Circle vs. Circle
69743-
return Phaser.Math.distance(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.radius + body2.radius);
69744-
}
69745-
else
69746-
{
69747-
// Circle vs. Rect
69748-
return this.circleBodyIntersects(body1, body2);
69749-
}
69769+
return false;
6975069770
}
69751-
else
69752-
{
69753-
if (body2.isCircle)
69754-
{
69755-
// Rect vs. Circle
69756-
return this.circleBodyIntersects(body2, body1);
69757-
}
69758-
else
69759-
{
69760-
// Rect vs. Rect
69761-
if (body1.right <= body2.position.x)
69762-
{
69763-
return false;
69764-
}
69765-
69766-
if (body1.bottom <= body2.position.y)
69767-
{
69768-
return false;
69769-
}
6977069771

69771-
if (body1.position.x >= body2.right)
69772-
{
69773-
return false;
69774-
}
69772+
if (body1.bottom <= body2.position.y)
69773+
{
69774+
return false;
69775+
}
6977569776

69776-
if (body1.position.y >= body2.bottom)
69777-
{
69778-
return false;
69779-
}
69777+
if (body1.position.x >= body2.right)
69778+
{
69779+
return false;
69780+
}
6978069781

69781-
return true;
69782-
}
69782+
if (body1.position.y >= body2.bottom)
69783+
{
69784+
return false;
6978369785
}
6978469786

69787+
return true;
69788+
6978569789
},
6978669790

6978769791
/**

build/custom/phaser-arcade-physics.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/phaser-arcade-physics.min.js

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)