mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Explicitly paused Timer continues if you un-focus and focus the browser window (thanks georgiee)
Added TimerEvent.pendingDelete and checks in Timer.update, so that removing an event in a callback no longer throws an exception (thanks georgiee) Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy) Added SAT.js to TypeScript definition. Now compiles properly. Added missing Line.js to the Grunt file. Tilemap#paste diffX and diffY equations changed, fixed issue #393 (thanks brejep) Added missing return value in Body.hitLeft and hitRight, fixes issue #398 (thanks ram64). Fixed easing tween example case. Issue #379 (thanks wesleywerner) Removed SAT.js UMD wrapped, fixes issue #361 (thanks luizbills)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||

|
||||
|
||||
Phaser 1.1.5-dev
|
||||
================
|
||||
Phaser 1.1.5
|
||||
============
|
||||
|
||||
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering.
|
||||
|
||||
Version: 1.1.5 "Saldaea" - Released: -in development-
|
||||
Version: 1.1.5 "Saldaea" - Released: 12th February 2014
|
||||
|
||||
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
|
||||
|
||||
@@ -23,6 +23,8 @@ By Richard Davey, [Photon Storm](http://www.photonstorm.com)
|
||||
Welcome to Phaser
|
||||
-----------------
|
||||
|
||||
This 1.1.5 release is released to address issues in 1.1.4 that we didn't want you to have to wait too long for.
|
||||
|
||||
As you may know we had planned to release 1.1.4 at the end of 2013. For various reasons this didn't quite happen, but we're happy to announce it's finally out! There have been some dramatic changes internally, and if you make use of either the physics systems or tilemaps then you are going to need to update your code. Hopefully only a little bit, but there have been a number of core API changes which we detail below. There are also a host of new features, the headliners being:
|
||||
|
||||
* New Physics system. Uses SAT.js internally so physics bodies can now be rectangles, circles or polygons and support rotation.
|
||||
@@ -44,6 +46,12 @@ Phaser is everything we ever wanted from an HTML5 game framework. It powers all
|
||||

|
||||
|
||||
|
||||
Help Test 1.2
|
||||
-------------
|
||||
|
||||
You'll notice a new [1.2 branch](https://github.com/photonstorm/phaser/tree/1.2) on github. Please help test out 1.2 as much as you can. It features the brand new Pixi 1.5 internally as well as nearly complete integration with p2.js for all physics (dropping ArcadePhysics entirely). New versions are being pushed several times a day, so be sure to update and pull often. Don't expect to just run old games right under it yet, but please do check out the new tests, experiment and poke it around as much as you can - thank you!
|
||||
|
||||
|
||||
Getting Started Guides
|
||||
----------------------
|
||||
|
||||
@@ -57,27 +65,23 @@ There is also an [un-official Getting Started Guide](http://www.antonoffplus.com
|
||||
Change Log
|
||||
----------
|
||||
|
||||
Version 1.1.5 - "Saldaea" - -in development-
|
||||
|
||||
Significant API changes:
|
||||
|
||||
|
||||
New features:
|
||||
|
||||
|
||||
New Examples:
|
||||
|
||||
|
||||
Updates:
|
||||
|
||||
Version 1.1.5 - "Saldaea" - 12th February 2014
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Explicitly paused Timer continues if you un-focus and focus the browser window (thanks georgiee)
|
||||
* Added TimerEvent.pendingDelete and checks in Timer.update, so that removing an event in a callback no longer throws an exception (thanks georgiee)
|
||||
* Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy)
|
||||
* Added SAT.js to TypeScript definition. Now compiles properly.
|
||||
* Added missing Line.js to the Grunt file.
|
||||
* Tilemap#paste diffX and diffY equations changed, fixed issue #393 (thanks brejep)
|
||||
* Added missing return value in Body.hitLeft and hitRight, fixes issue #398 (thanks ram64).
|
||||
* Fixed easing tween example case. Issue #379 (thanks wesleywerner)
|
||||
* Removed SAT.js UMD wrapped, fixes issue #361 (thanks luizbills)
|
||||
|
||||
|
||||
See the full Change Log for all the 1.1.4 updates and API changes (as there were a lot of them!)
|
||||
|
||||
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||
|
||||
|
||||
@@ -114,11 +118,11 @@ CDNJS
|
||||
|
||||
Thanks to a community member Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html:
|
||||
|
||||
`http://cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js`
|
||||
`http://cdnjs.cloudflare.com/ajax/libs/phaser/1.1.4/phaser.min.js`
|
||||
|
||||
Or if you prefer you can leave the protocol off, so it works via http and https:
|
||||
|
||||
`//cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js`
|
||||
`//cdnjs.cloudflare.com/ajax/libs/phaser/1.1.4/phaser.min.js`
|
||||
|
||||
|
||||
Requirements
|
||||
@@ -227,7 +231,7 @@ Here is what's on our road map for the coming months:
|
||||
|
||||
Version 1.2 ("Shienar")
|
||||
|
||||
* Update to Pixi 1.4 - this newly released build has lots of internal changes and new features we want to take advantage of.
|
||||
* Update to Pixi 1.5 - this newly released build has lots of internal changes and new features we want to take advantage of.
|
||||
|
||||
Version 1.3 ("Tarabon")
|
||||
|
||||
|
||||
+109
-102
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v1.1.4 - Built at: Wed Feb 05 2014 16:54:13
|
||||
* v1.1.5 - Built at: Wed Feb 12 2014 15:08:44
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
@@ -57,8 +57,8 @@ var PIXI = PIXI || {};
|
||||
*/
|
||||
var Phaser = Phaser || {
|
||||
|
||||
VERSION: '1.1.4',
|
||||
DEV_VERSION: '1.1.4',
|
||||
VERSION: '1.1.5',
|
||||
DEV_VERSION: '1.1.5',
|
||||
GAMES: [],
|
||||
|
||||
AUTO: 0,
|
||||
@@ -139,9 +139,9 @@ Phaser.Utils = {
|
||||
* dir = 1 (left), 2 (right), 3 (both)
|
||||
* @method Phaser.Utils.pad
|
||||
* @param {string} str - The target string.
|
||||
* @param {number} len - Description.
|
||||
* @param {number} pad - the string to pad it out with (defaults to a space).
|
||||
* @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both).
|
||||
* @param {number} len - The number of characters to be added.
|
||||
* @param {number} pad - The string to pad it out with (defaults to a space).
|
||||
* @param {number} [dir=3] The direction dir = 1 (left), 2 (right), 3 (both).
|
||||
* @return {string} The padded string
|
||||
*/
|
||||
pad: function (str, len, pad, dir) {
|
||||
@@ -31173,7 +31173,7 @@ Phaser.Timer.prototype = {
|
||||
{
|
||||
if (this.events[i] === event)
|
||||
{
|
||||
this.events.splice(i, 1);
|
||||
this.events[i].pendingDelete = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -31236,6 +31236,21 @@ Phaser.Timer.prototype = {
|
||||
|
||||
this._len = this.events.length;
|
||||
|
||||
this._i = 0;
|
||||
|
||||
while (this._i < this._len)
|
||||
{
|
||||
if (this.events[this._i].pendingDelete)
|
||||
{
|
||||
this.events.splice(this._i, 1);
|
||||
this._len--;
|
||||
}
|
||||
|
||||
this._i++;
|
||||
}
|
||||
|
||||
this._len = this.events.length;
|
||||
|
||||
if (this.running && this._now >= this.nextTick && this._len > 0)
|
||||
{
|
||||
this._i = 0;
|
||||
@@ -31299,9 +31314,12 @@ Phaser.Timer.prototype = {
|
||||
*/
|
||||
pause: function () {
|
||||
|
||||
this._pauseStarted = this.game.time.now;
|
||||
if (this.running && !this.expired)
|
||||
{
|
||||
this._pauseStarted = this.game.time.now;
|
||||
|
||||
this.paused = true;
|
||||
this.paused = true;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -31311,17 +31329,20 @@ Phaser.Timer.prototype = {
|
||||
*/
|
||||
resume: function () {
|
||||
|
||||
var pauseDuration = this.game.time.now - this._pauseStarted;
|
||||
|
||||
for (var i = 0; i < this.events.length; i++)
|
||||
if (this.running && !this.expired)
|
||||
{
|
||||
this.events[i].tick += pauseDuration;
|
||||
var pauseDuration = this.game.time.now - this._pauseStarted;
|
||||
|
||||
for (var i = 0; i < this.events.length; i++)
|
||||
{
|
||||
this.events[i].tick += pauseDuration;
|
||||
}
|
||||
|
||||
this.nextTick += pauseDuration;
|
||||
|
||||
this.paused = false;
|
||||
}
|
||||
|
||||
this.nextTick += pauseDuration;
|
||||
|
||||
this.paused = false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -31333,6 +31354,7 @@ Phaser.Timer.prototype = {
|
||||
this.onComplete.removeAll();
|
||||
this.running = false;
|
||||
this.events = [];
|
||||
this._i = this._len;
|
||||
|
||||
}
|
||||
|
||||
@@ -31478,6 +31500,12 @@ Phaser.TimerEvent = function (timer, delay, tick, repeatCount, loop, callback, c
|
||||
*/
|
||||
this.args = args;
|
||||
|
||||
/**
|
||||
* @property {boolean} pendingDelete - A flag that controls if the TimerEvent is pending deletion.
|
||||
* @protected
|
||||
*/
|
||||
this.pendingDelete = false;
|
||||
|
||||
};
|
||||
|
||||
Phaser.TimerEvent.prototype.constructor = Phaser.TimerEvent;
|
||||
@@ -37955,33 +37983,7 @@ Phaser.Color = {
|
||||
// polygons using the Separating Axis Theorem.
|
||||
/** @preserve SAT.js - Version 0.2 - Copyright 2013 - Jim Riecken <jimr@jimr.ca> - released under the MIT License. https://github.com/jriecken/sat-js */
|
||||
|
||||
/*global define: false, module: false*/
|
||||
/*jshint shadow:true, sub:true, forin:true, noarg:true, noempty:true,
|
||||
eqeqeq:true, bitwise:true, strict:true, undef:true,
|
||||
curly:true, browser:true */
|
||||
|
||||
// Create a UMD wrapper for SAT. Works in:
|
||||
//
|
||||
// - Plain browser via global SAT variable
|
||||
// - AMD loader (like require.js)
|
||||
// - Node.js
|
||||
//
|
||||
// The quoted properties all over the place are used so that the Closure Compiler
|
||||
// does not mangle the exposed API in advanced mode.
|
||||
/**
|
||||
* @param {*} root - The global scope
|
||||
* @param {Function} factory - Factory that creates SAT module
|
||||
*/
|
||||
(function (root, factory) {
|
||||
"use strict";
|
||||
if (typeof define === 'function' && define['amd']) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module['exports'] = factory();
|
||||
} else {
|
||||
root['SAT'] = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
var SAT = (function () {
|
||||
"use strict";
|
||||
|
||||
var SAT = {};
|
||||
@@ -37994,7 +37996,7 @@ Phaser.Color = {
|
||||
|
||||
// Create a new Vector, optionally passing in the `x` and `y` coordinates. If
|
||||
// a coordinate is not specified, it will be set to `0`
|
||||
/**
|
||||
/**
|
||||
* @param {?number=} x The x position.
|
||||
* @param {?number=} y The y position.
|
||||
* @constructor
|
||||
@@ -38067,7 +38069,7 @@ Phaser.Color = {
|
||||
this['y'] = -this['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Normalize this vector. (make it have length of `1`)
|
||||
/**
|
||||
@@ -38081,7 +38083,7 @@ Phaser.Color = {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Add another vector to this one.
|
||||
/**
|
||||
* @param {Vector} other The other Vector.
|
||||
@@ -38092,7 +38094,7 @@ Phaser.Color = {
|
||||
this['y'] += other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Subtract another vector from this one.
|
||||
/**
|
||||
* @param {Vector} other The other Vector.
|
||||
@@ -38103,7 +38105,7 @@ Phaser.Color = {
|
||||
this['y'] -= other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Scale this vector. An independant scaling factor can be provided
|
||||
// for each axis, or a single scaling factor that will scale both `x` and `y`.
|
||||
/**
|
||||
@@ -38115,9 +38117,9 @@ Phaser.Color = {
|
||||
Vector.prototype['scale'] = Vector.prototype.scale = function(x,y) {
|
||||
this['x'] *= x;
|
||||
this['y'] *= y || x;
|
||||
return this;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Project this vector on to another vector.
|
||||
/**
|
||||
* @param {Vector} other The vector to project onto.
|
||||
@@ -38129,7 +38131,7 @@ Phaser.Color = {
|
||||
this['y'] = amt * other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Project this vector onto a vector of unit length. This is slightly more efficient
|
||||
// than `project` when dealing with unit vectors.
|
||||
/**
|
||||
@@ -38142,7 +38144,7 @@ Phaser.Color = {
|
||||
this['y'] = amt * other['y'];
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Reflect this vector on an arbitrary axis.
|
||||
/**
|
||||
* @param {Vector} axis The vector representing the axis.
|
||||
@@ -38156,7 +38158,7 @@ Phaser.Color = {
|
||||
this['y'] -= y;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Reflect this vector on an arbitrary axis (represented by a unit vector). This is
|
||||
// slightly more efficient than `reflect` when dealing with an axis that is a unit vector.
|
||||
/**
|
||||
@@ -38171,7 +38173,7 @@ Phaser.Color = {
|
||||
this['y'] -= y;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
// Get the dot product of this vector and another.
|
||||
/**
|
||||
* @param {Vector} other The vector to dot this one against.
|
||||
@@ -38180,7 +38182,7 @@ Phaser.Color = {
|
||||
Vector.prototype['dot'] = Vector.prototype.dot = function(other) {
|
||||
return this['x'] * other['x'] + this['y'] * other['y'];
|
||||
};
|
||||
|
||||
|
||||
// Get the squared length of this vector.
|
||||
/**
|
||||
* @return {number} The length^2 of this vector.
|
||||
@@ -38188,7 +38190,7 @@ Phaser.Color = {
|
||||
Vector.prototype['len2'] = Vector.prototype.len2 = function() {
|
||||
return this.dot(this);
|
||||
};
|
||||
|
||||
|
||||
// Get the length of this vector.
|
||||
/**
|
||||
* @return {number} The length of this vector.
|
||||
@@ -38196,7 +38198,7 @@ Phaser.Color = {
|
||||
Vector.prototype['len'] = Vector.prototype.len = function() {
|
||||
return Math.sqrt(this.len2());
|
||||
};
|
||||
|
||||
|
||||
// ## Circle
|
||||
//
|
||||
// Represents a circle with a position and a radius.
|
||||
@@ -38239,7 +38241,7 @@ Phaser.Color = {
|
||||
this.recalc();
|
||||
}
|
||||
SAT['Polygon'] = Polygon;
|
||||
|
||||
|
||||
// Recalculates the edges and normals of the polygon. This **must** be called
|
||||
// if the `points` array is modified at all and the edges or normals are to be
|
||||
// accessed.
|
||||
@@ -38258,7 +38260,7 @@ Phaser.Color = {
|
||||
var points = this['points'];
|
||||
var len = points.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var p1 = points[i];
|
||||
var p1 = points[i];
|
||||
var p2 = i < len - 1 ? points[i + 1] : points[0];
|
||||
var e = new Vector().copy(p2).sub(p1);
|
||||
var n = new Vector().copy(e).perp().normalize();
|
||||
@@ -38367,11 +38369,11 @@ Phaser.Color = {
|
||||
var w = this['w'];
|
||||
var h = this['h'];
|
||||
return new Polygon(new Vector(pos['x'], pos['y']), [
|
||||
new Vector(), new Vector(w, 0),
|
||||
new Vector(), new Vector(w, 0),
|
||||
new Vector(w,h), new Vector(0,h)
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
// ## Response
|
||||
//
|
||||
// An object representing the result of an intersection. Contains:
|
||||
@@ -38382,7 +38384,7 @@ Phaser.Color = {
|
||||
// - Whether the first object is entirely inside the second, and vice versa.
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
*/
|
||||
function Response() {
|
||||
this['a'] = null;
|
||||
this['b'] = null;
|
||||
@@ -38414,7 +38416,7 @@ Phaser.Color = {
|
||||
*/
|
||||
var T_VECTORS = [];
|
||||
for (var i = 0; i < 10; i++) { T_VECTORS.push(new Vector()); }
|
||||
|
||||
|
||||
// A pool of arrays of numbers used in calculations to avoid allocating
|
||||
// memory.
|
||||
/**
|
||||
@@ -38447,7 +38449,7 @@ Phaser.Color = {
|
||||
}
|
||||
result[0] = min; result[1] = max;
|
||||
}
|
||||
|
||||
|
||||
// Check whether two convex polygons are separated by the specified
|
||||
// axis (must be a unit vector).
|
||||
/**
|
||||
@@ -38477,8 +38479,8 @@ Phaser.Color = {
|
||||
rangeB[1] += projectedOffset;
|
||||
// Check if there is a gap. If there is, this is a separating axis and we can stop
|
||||
if (rangeA[0] > rangeB[1] || rangeB[0] > rangeA[1]) {
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_ARRAYS.push(rangeB);
|
||||
return true;
|
||||
}
|
||||
@@ -38489,7 +38491,7 @@ Phaser.Color = {
|
||||
if (rangeA[0] < rangeB[0]) {
|
||||
response['aInB'] = false;
|
||||
// A ends before B does. We have to pull A out of B
|
||||
if (rangeA[1] < rangeB[1]) {
|
||||
if (rangeA[1] < rangeB[1]) {
|
||||
overlap = rangeA[1] - rangeB[0];
|
||||
response['bInA'] = false;
|
||||
// B is fully inside A. Pick the shortest way out.
|
||||
@@ -38502,7 +38504,7 @@ Phaser.Color = {
|
||||
} else {
|
||||
response['bInA'] = false;
|
||||
// B ends before A ends. We have to push A out of B
|
||||
if (rangeA[1] > rangeB[1]) {
|
||||
if (rangeA[1] > rangeB[1]) {
|
||||
overlap = rangeA[0] - rangeB[1];
|
||||
response['aInB'] = false;
|
||||
// A is fully inside B. Pick the shortest way out.
|
||||
@@ -38520,14 +38522,14 @@ Phaser.Color = {
|
||||
if (overlap < 0) {
|
||||
response['overlapN'].reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_VECTORS.push(offsetV);
|
||||
T_ARRAYS.push(rangeA);
|
||||
T_ARRAYS.push(rangeB);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Calculates which Vornoi region a point is on a line segment.
|
||||
// It is assumed that both the line and the point are relative to `(0,0)`
|
||||
//
|
||||
@@ -38537,8 +38539,8 @@ Phaser.Color = {
|
||||
/**
|
||||
* @param {Vector} line The line segment.
|
||||
* @param {Vector} point The point.
|
||||
* @return {number} LEFT_VORNOI_REGION (-1) if it is the left region,
|
||||
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
||||
* @return {number} LEFT_VORNOI_REGION (-1) if it is the left region,
|
||||
* MIDDLE_VORNOI_REGION (0) if it is the middle region,
|
||||
* RIGHT_VORNOI_REGION (1) if it is the right region.
|
||||
*/
|
||||
function vornoiRegion(line, point) {
|
||||
@@ -38566,7 +38568,7 @@ Phaser.Color = {
|
||||
* @const
|
||||
*/
|
||||
var RIGHT_VORNOI_REGION = 1;
|
||||
|
||||
|
||||
// ## Collision Tests
|
||||
|
||||
// Check if two circles collide.
|
||||
@@ -38575,7 +38577,7 @@ Phaser.Color = {
|
||||
* @param {Circle} b The second circle.
|
||||
* @param {Response=} response Response object (optional) that will be populated if
|
||||
* the circles intersect.
|
||||
* @return {boolean} true if the circles intersect, false if they don't.
|
||||
* @return {boolean} true if the circles intersect, false if they don't.
|
||||
*/
|
||||
function testCircleCircle(a, b, response) {
|
||||
// Check if the distance between the centers of the two
|
||||
@@ -38590,7 +38592,7 @@ Phaser.Color = {
|
||||
return false;
|
||||
}
|
||||
// They intersect. If we're calculating a response, calculate the overlap.
|
||||
if (response) {
|
||||
if (response) {
|
||||
var dist = Math.sqrt(distanceSq);
|
||||
response['a'] = a;
|
||||
response['b'] = b;
|
||||
@@ -38604,7 +38606,7 @@ Phaser.Color = {
|
||||
return true;
|
||||
}
|
||||
SAT['testCircleCircle'] = testCircleCircle;
|
||||
|
||||
|
||||
// Check if a polygon and a circle collide.
|
||||
/**
|
||||
* @param {Polygon} polygon The polygon.
|
||||
@@ -38622,30 +38624,30 @@ Phaser.Color = {
|
||||
var len = points.length;
|
||||
var edge = T_VECTORS.pop();
|
||||
var point = T_VECTORS.pop();
|
||||
|
||||
|
||||
// For each edge in the polygon:
|
||||
for (var i = 0; i < len; i++) {
|
||||
var next = i === len - 1 ? 0 : i + 1;
|
||||
var prev = i === 0 ? len - 1 : i - 1;
|
||||
var overlap = 0;
|
||||
var overlapN = null;
|
||||
|
||||
|
||||
// Get the edge.
|
||||
edge.copy(polygon['edges'][i]);
|
||||
// Calculate the center of the circle relative to the starting point of the edge.
|
||||
point.copy(circlePos).sub(points[i]);
|
||||
|
||||
|
||||
// If the distance between the center of the circle and the point
|
||||
// is bigger than the radius, the polygon is definitely not fully in
|
||||
// the circle.
|
||||
if (response && point.len2() > radius2) {
|
||||
response['aInB'] = false;
|
||||
}
|
||||
|
||||
|
||||
// Calculate which Vornoi region the center of the circle is in.
|
||||
var region = vornoiRegion(edge, point);
|
||||
// If it's the left region:
|
||||
if (region === LEFT_VORNOI_REGION) {
|
||||
if (region === LEFT_VORNOI_REGION) {
|
||||
// We need to make sure we're in the RIGHT_VORNOI_REGION of the previous edge.
|
||||
edge.copy(polygon['edges'][prev]);
|
||||
// Calculate the center of the circle relative the starting point of the previous edge
|
||||
@@ -38656,9 +38658,9 @@ Phaser.Color = {
|
||||
var dist = point.len();
|
||||
if (dist > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
T_VECTORS.push(point);
|
||||
T_VECTORS.push(point2);
|
||||
return false;
|
||||
} else if (response) {
|
||||
@@ -38681,10 +38683,10 @@ Phaser.Color = {
|
||||
var dist = point.len();
|
||||
if (dist > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
return false;
|
||||
return false;
|
||||
} else if (response) {
|
||||
// It intersects, calculate the overlap.
|
||||
response['bInA'] = false;
|
||||
@@ -38697,15 +38699,15 @@ Phaser.Color = {
|
||||
// Need to check if the circle is intersecting the edge,
|
||||
// Change the edge into its "edge normal".
|
||||
var normal = edge.perp().normalize();
|
||||
// Find the perpendicular distance between the center of the
|
||||
// Find the perpendicular distance between the center of the
|
||||
// circle and the edge.
|
||||
var dist = point.dot(normal);
|
||||
var distAbs = Math.abs(dist);
|
||||
// If the circle is on the outside of the edge, there is no intersection.
|
||||
if (dist > 0 && distAbs > radius) {
|
||||
// No intersection
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(normal);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(normal);
|
||||
T_VECTORS.push(point);
|
||||
return false;
|
||||
} else if (response) {
|
||||
@@ -38719,28 +38721,28 @@ Phaser.Color = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the smallest overlap we've seen, keep it.
|
||||
|
||||
// If this is the smallest overlap we've seen, keep it.
|
||||
// (overlapN may be null if the circle was in the wrong Vornoi region).
|
||||
if (overlapN && response && Math.abs(overlap) < Math.abs(response['overlap'])) {
|
||||
response['overlap'] = overlap;
|
||||
response['overlapN'].copy(overlapN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Calculate the final overlap vector - based on the smallest overlap.
|
||||
if (response) {
|
||||
response['a'] = polygon;
|
||||
response['b'] = circle;
|
||||
response['overlapV'].copy(response['overlapN']).scale(response['overlap']);
|
||||
}
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(circlePos);
|
||||
T_VECTORS.push(edge);
|
||||
T_VECTORS.push(point);
|
||||
return true;
|
||||
}
|
||||
SAT['testPolygonCircle'] = testPolygonCircle;
|
||||
|
||||
|
||||
// Check if a circle and a polygon collide.
|
||||
//
|
||||
// **NOTE:** This is slightly less efficient than polygonCircle as it just
|
||||
@@ -38769,7 +38771,7 @@ Phaser.Color = {
|
||||
return result;
|
||||
}
|
||||
SAT['testCirclePolygon'] = testCirclePolygon;
|
||||
|
||||
|
||||
// Checks whether polygons collide.
|
||||
/**
|
||||
* @param {Polygon} a The first polygon.
|
||||
@@ -38808,7 +38810,8 @@ Phaser.Color = {
|
||||
SAT['testPolygonPolygon'] = testPolygonPolygon;
|
||||
|
||||
return SAT;
|
||||
}));
|
||||
})();
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
@@ -41223,7 +41226,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.LEFT, this, body, response))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.right || this.touching.right)
|
||||
@@ -41247,6 +41250,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.left = true;
|
||||
body.touching.right = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -41270,7 +41275,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.RIGHT, this, body))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.left || this.touching.left)
|
||||
@@ -41294,6 +41299,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.right = true;
|
||||
body.touching.left = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+7
-7
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@ var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: p
|
||||
function preload() {
|
||||
|
||||
game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 138, 15);
|
||||
game.load.spritesheet('phaser', 'assets/tests/tween/phaser.png', 70, 90);
|
||||
game.load.spritesheet('phaser', 'assets/tests/tween/PHASER.png', 70, 90);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -980,7 +980,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.LEFT, this, body, response))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.right || this.touching.right)
|
||||
@@ -1004,6 +1004,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.left = true;
|
||||
body.touching.right = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1027,7 +1029,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.collideCallback && !this.collideCallback.call(this.collideCallbackContext, Phaser.RIGHT, this, body))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.moves || this.immovable || this.blocked.left || this.touching.left)
|
||||
@@ -1051,6 +1053,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
this.touching.right = true;
|
||||
body.touching.left = true;
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user