Skip to content

Commit bcd64fd

Browse files
committed
More Timer tests.
1 parent 1209d67 commit bcd64fd

9 files changed

Lines changed: 223 additions & 85 deletions

File tree

build/custom/p2.js

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11150,6 +11150,12 @@ Phaser.Physics.P2 = function (game, config) {
1115011150
*/
1115111151
this.useElapsedTime = false;
1115211152

11153+
/**
11154+
* @property {boolean} paused - The paused state of the P2 World.
11155+
* @default
11156+
*/
11157+
this.paused = false;
11158+
1115311159
/**
1115411160
* @property {array<Phaser.Physics.P2.Material>} materials - A local array of all created Materials.
1115511161
* @protected
@@ -11733,10 +11739,40 @@ Phaser.Physics.P2.prototype = {
1173311739
},
1173411740

1173511741
/**
11742+
* Pauses the P2 World independent of the game pause state.
11743+
*
11744+
* @method Phaser.Physics.P2#pause
11745+
*/
11746+
pause: function() {
11747+
11748+
this.paused = true;
11749+
11750+
},
11751+
11752+
/**
11753+
* Resumes a paused P2 World.
11754+
*
11755+
* @method Phaser.Physics.P2#resume
11756+
*/
11757+
resume: function() {
11758+
11759+
this.paused = false;
11760+
11761+
},
11762+
11763+
/**
11764+
* Internal P2 update loop.
11765+
*
1173611766
* @method Phaser.Physics.P2#update
1173711767
*/
1173811768
update: function () {
1173911769

11770+
// Do nothing when the pysics engine was paused before
11771+
if (this.paused)
11772+
{
11773+
return;
11774+
}
11775+
1174011776
if (this.useElapsedTime)
1174111777
{
1174211778
this.world.step(this.game.time.physicsElapsed);
@@ -12094,7 +12130,7 @@ Phaser.Physics.P2.prototype = {
1209412130

1209512131
while (i--)
1209612132
{
12097-
bodies.setMaterial(material);
12133+
bodies[i].setMaterial(material);
1209812134
}
1209912135

1210012136
},
@@ -14439,7 +14475,7 @@ Phaser.Physics.P2.Body.prototype = {
1443914475
},
1444014476

1444114477
/**
14442-
* Add a polygon fixture. This is used during #loadPhaserPolygon.
14478+
* Add a polygon fixture. This is used during #loadPolygon.
1444314479
*
1444414480
* @method Phaser.Physics.P2.Body#addFixture
1444514481
* @param {string} fixtureData - The data for the fixture. It contains: isSensor, filter (collision) and the actual polygon shapes.
@@ -14516,97 +14552,70 @@ Phaser.Physics.P2.Body.prototype = {
1451614552
* @method Phaser.Physics.P2.Body#loadPolygon
1451714553
* @param {string} key - The key of the Physics Data file as stored in Game.Cache.
1451814554
* @param {string} object - The key of the object within the Physics data file that you wish to load the shape data from.
14519-
* @param {object} options - An object containing the build options. Note that this isn't used if the data file contains multiple shapes.
14520-
* @param {boolean} [options.optimalDecomp=false] - Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
14521-
* @param {boolean} [options.skipSimpleCheck=false] - Set to true if you already know that the path is not intersecting itself.
14522-
* @param {boolean|number} [options.removeCollinearPoints=false] - Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
1452314555
* @return {boolean} True on success, else false.
1452414556
*/
14525-
loadPolygon: function (key, object, options) {
14557+
loadPolygon: function (key, object) {
1452614558

1452714559
var data = this.game.cache.getPhysicsData(key, object);
1452814560

14529-
if (data.length === 1)
14561+
// We've multiple Convex shapes, they should be CCW automatically
14562+
var cm = p2.vec2.create();
14563+
14564+
for (var i = 0; i < data.length; i++)
1453014565
{
14531-
var temp = [];
14532-
var localData = data[data.length - 1];
14566+
var vertices = [];
1453314567

14534-
// We've a list of numbers
14535-
for (var i = 0, len = localData.shape.length; i < len; i += 2)
14568+
for (var s = 0; s < data[i].shape.length; s += 2)
1453614569
{
14537-
temp.push([localData.shape[i], localData.shape[i + 1]]);
14570+
vertices.push([ this.world.pxmi(data[i].shape[s]), this.world.pxmi(data[i].shape[s + 1]) ]);
1453814571
}
1453914572

14540-
return this.addPolygon(options, temp);
14541-
}
14542-
else
14543-
{
14544-
// We've multiple Convex shapes, they should be CCW automatically
14545-
var cm = p2.vec2.create();
14573+
var c = new p2.Convex(vertices);
1454614574

14547-
for (var i = 0; i < data.length; i++)
14575+
// Move all vertices so its center of mass is in the local center of the convex
14576+
for (var j = 0; j !== c.vertices.length; j++)
1454814577
{
14549-
var vertices = [];
14550-
14551-
for (var s = 0; s < data[i].shape.length; s += 2)
14552-
{
14553-
vertices.push([ this.world.pxmi(data[i].shape[s]), this.world.pxmi(data[i].shape[s + 1]) ]);
14554-
}
14555-
14556-
var c = new p2.Convex(vertices);
14557-
14558-
// Move all vertices so its center of mass is in the local center of the convex
14559-
for (var j = 0; j !== c.vertices.length; j++)
14560-
{
14561-
var v = c.vertices[j];
14562-
p2.vec2.sub(v, v, c.centerOfMass);
14563-
}
14564-
14565-
p2.vec2.scale(cm, c.centerOfMass, 1);
14566-
14567-
cm[0] -= this.world.pxmi(this.sprite.width / 2);
14568-
cm[1] -= this.world.pxmi(this.sprite.height / 2);
14569-
14570-
c.updateTriangles();
14571-
c.updateCenterOfMass();
14572-
c.updateBoundingRadius();
14573-
14574-
this.data.addShape(c, cm);
14578+
var v = c.vertices[j];
14579+
p2.vec2.sub(v, v, c.centerOfMass);
1457514580
}
1457614581

14577-
this.data.aabbNeedsUpdate = true;
14578-
this.shapeChanged();
14582+
p2.vec2.scale(cm, c.centerOfMass, 1);
1457914583

14580-
return true;
14584+
cm[0] -= this.world.pxmi(this.sprite.width / 2);
14585+
cm[1] -= this.world.pxmi(this.sprite.height / 2);
14586+
14587+
c.updateTriangles();
14588+
c.updateCenterOfMass();
14589+
c.updateBoundingRadius();
1458114590

14591+
this.data.addShape(c, cm);
1458214592
}
1458314593

14584-
return false;
14594+
this.data.aabbNeedsUpdate = true;
14595+
this.shapeChanged();
14596+
14597+
return true;
1458514598

1458614599
},
1458714600

1458814601
/**
14602+
* DEPRECATED: This method will soon be removed from the API. Please avoid using.
1458914603
* Reads the physics data from a physics data file stored in the Game.Cache.
14590-
* It will add the shape data to this Body, as well as set the density (mass), friction and bounce (restitution) values.
14604+
* It will add the shape data to this Body, as well as set the density (mass).
1459114605
*
14592-
* @method Phaser.Physics.P2.Body#loadPolygon
14606+
* @method Phaser.Physics.P2.Body#loadData
1459314607
* @param {string} key - The key of the Physics Data file as stored in Game.Cache.
1459414608
* @param {string} object - The key of the object within the Physics data file that you wish to load the shape data from.
14595-
* @param {object} options - An object containing the build options:
14596-
* @param {boolean} [options.optimalDecomp=false] - Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
14597-
* @param {boolean} [options.skipSimpleCheck=false] - Set to true if you already know that the path is not intersecting itself.
14598-
* @param {boolean|number} [options.removeCollinearPoints=false] - Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
1459914609
* @return {boolean} True on success, else false.
1460014610
*/
14601-
loadData: function (key, object, options) {
14611+
loadData: function (key, object) {
1460214612

1460314613
var data = this.game.cache.getPhysicsData(key, object);
1460414614

1460514615
if (data && data.shape)
1460614616
{
1460714617
this.mass = data.density;
14608-
this.loadPolygon(key, object, options);
14609-
// TODO set friction + bounce here
14618+
return this.loadPolygon(key, object);
1461014619
}
1461114620

1461214621
}

build/custom/p2.min.js

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

build/custom/pixi.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,53 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
22512251
};
22522252

22532253

2254+
/**
2255+
* @author Mat Groves http://matgroves.com/ @Doormat23
2256+
*/
2257+
2258+
/**
2259+
* This is the base class for creating a pixi.js filter. Currently only webGL supports filters.
2260+
* If you want to make a custom filter this should be your base class.
2261+
* @class AbstractFilter
2262+
* @constructor
2263+
* @param fragmentSrc
2264+
* @param uniforms
2265+
*/
2266+
PIXI.AbstractFilter = function(fragmentSrc, uniforms)
2267+
{
2268+
/**
2269+
* An array of passes - some filters contain a few steps this array simply stores the steps in a liniear fashion.
2270+
* For example the blur filter has two passes blurX and blurY.
2271+
* @property passes
2272+
* @type Array an array of filter objects
2273+
* @private
2274+
*/
2275+
this.passes = [this];
2276+
2277+
/**
2278+
* @property shaders
2279+
* @type Array an array of shaders
2280+
* @private
2281+
*/
2282+
this.shaders = [];
2283+
2284+
this.dirty = true;
2285+
this.padding = 0;
2286+
2287+
/**
2288+
* @property uniforms
2289+
* @type object
2290+
* @private
2291+
*/
2292+
this.uniforms = uniforms || {};
2293+
/**
2294+
* @property fragmentSrc
2295+
* @type Array
2296+
* @private
2297+
*/
2298+
this.fragmentSrc = fragmentSrc || [];
2299+
};
2300+
22542301
/**
22552302
* @author Mat Groves http://matgroves.com/ @Doormat23
22562303
*/

build/custom/pixi.min.js

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

src/Outro.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@
1515
root.Phaser = Phaser;
1616
}
1717
}).call(this);
18+
19+
/*
20+
* "Don't follow strange women who lure you into woods with beautiful poetry." - @djfood
21+
*/

src/Phaser.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
*/
1111
var Phaser = Phaser || {
1212

13-
VERSION: '<%= version %>',
14-
DEV_VERSION: '2.0.4',
13+
VERSION: '2.0.4',
1514
GAMES: [],
1615

1716
AUTO: 0,

src/core/Game.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Phaser.Game.prototype = {
486486
*/
487487
showDebugHeader: function () {
488488

489-
var v = Phaser.DEV_VERSION;
489+
var v = Phaser.VERSION;
490490
var r = 'Canvas';
491491
var a = 'HTML Audio';
492492
var c = 1;

src/time/Time.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,23 @@ Phaser.Time.prototype = {
319319
*/
320320
gameResumed: function () {
321321

322-
this.pauseDuration = Date.now() - this._pauseStarted;
323-
324322
// Level out the elapsed timer to avoid spikes
325323
this.time = Date.now();
326324

325+
this.pauseDuration = this.time - this._pauseStarted;
326+
327327
this._justResumed = true;
328328

329+
this.events.resume();
330+
331+
// var i = this._timers.length;
332+
333+
// while (i--)
334+
// {
335+
// this._timers[i]._resume();
336+
// }
337+
338+
329339
},
330340

331341
/**

0 commit comments

Comments
 (0)