mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a1c98d4831
13 changed files with 76 additions and 17 deletions
|
@ -65,7 +65,7 @@ var TransformMatrix = new Class({
|
|||
var radianSin = Math.sin(radian);
|
||||
var radianCos = Math.cos(radian);
|
||||
|
||||
return this.transform(radianCos, -radianSin, radianSin, radianCos, 0, 0);
|
||||
return this.transform(radianCos, radianSin, -radianSin, radianCos, 0, 0);
|
||||
},
|
||||
|
||||
multiply: function (otherMatrix)
|
||||
|
|
|
@ -44,6 +44,7 @@ var Graphics = new Class({
|
|||
this.defaultStrokeWidth = 1;
|
||||
this.defaultStrokeColor = -1;
|
||||
this.defaultStrokeAlpha = 1;
|
||||
this._lineWidth = 1.0;
|
||||
|
||||
this.setDefaultStyles(options);
|
||||
|
||||
|
@ -89,6 +90,8 @@ var Graphics = new Class({
|
|||
lineWidth, color, alpha
|
||||
);
|
||||
|
||||
this._lineWidth = lineWidth;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -198,13 +201,33 @@ var Graphics = new Class({
|
|||
|
||||
strokeRect: function (x, y, width, height)
|
||||
{
|
||||
var lineWidthHalf = this._lineWidth / 2;
|
||||
var minx = x - lineWidthHalf;
|
||||
var maxx = x + lineWidthHalf;
|
||||
|
||||
this.beginPath();
|
||||
this.moveTo(x, y);
|
||||
this.lineTo(x + width, y);
|
||||
this.lineTo(x + width, y + height);
|
||||
this.lineTo(x, y + height);
|
||||
this.closePath();
|
||||
this.strokePath();
|
||||
this.closePath();
|
||||
|
||||
this.beginPath();
|
||||
this.moveTo(x + width, y);
|
||||
this.lineTo(x + width, y + height);
|
||||
this.strokePath();
|
||||
this.closePath();
|
||||
|
||||
this.beginPath();
|
||||
this.moveTo(minx, y);
|
||||
this.lineTo(maxx + width, y);
|
||||
this.strokePath();
|
||||
this.closePath();
|
||||
|
||||
this.beginPath();
|
||||
this.moveTo(minx, y + height);
|
||||
this.lineTo(maxx + width, y + height);
|
||||
this.strokePath();
|
||||
this.closePath();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
|
|
@ -72,6 +72,31 @@ var Factory = new Class({
|
|||
return body;
|
||||
},
|
||||
|
||||
imageStack: function (key, frame, x, y, columns, rows, columnGap, rowGap, options)
|
||||
{
|
||||
if (columnGap === undefined) { columnGap = 0; }
|
||||
if (rowGap === undefined) { rowGap = 0; }
|
||||
if (options === undefined) { options = {}; }
|
||||
|
||||
var world = this.world;
|
||||
var displayList = this.sys.displayList;
|
||||
|
||||
options.addToWorld = false;
|
||||
|
||||
var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, function (x, y)
|
||||
{
|
||||
var image = new MatterImage(world, x, y, key, frame, options);
|
||||
|
||||
displayList.add(image);
|
||||
|
||||
return image.body;
|
||||
});
|
||||
|
||||
world.add(stack);
|
||||
|
||||
return stack;
|
||||
},
|
||||
|
||||
stack: function (x, y, columns, rows, columnGap, rowGap, callback)
|
||||
{
|
||||
var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, callback);
|
||||
|
|
|
@ -54,7 +54,10 @@ var MatterImage = new Class({
|
|||
|
||||
this.world = world;
|
||||
|
||||
if (GetFastValue(options, 'addToWorld', true))
|
||||
{
|
||||
world.add(this.body);
|
||||
}
|
||||
|
||||
this.setPosition(x, y);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,10 @@ var MatterSprite = new Class({
|
|||
|
||||
this.world = world;
|
||||
|
||||
if (GetFastValue(options, 'addToWorld', true))
|
||||
{
|
||||
world.add(this.body);
|
||||
}
|
||||
|
||||
this.setPosition(x, y);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ var PointerConstraint = new Class({
|
|||
{
|
||||
var body = bodies[i];
|
||||
|
||||
if (Bounds.contains(body.bounds, position) &&
|
||||
if (!body.ignorePointer && Bounds.contains(body.bounds, position) &&
|
||||
Detector.canCollide(body.collisionFilter, constraint.collisionFilter))
|
||||
{
|
||||
if (this.getBodyPart(body, position))
|
||||
|
|
|
@ -123,7 +123,7 @@ var World = new Class({
|
|||
if (y === undefined) { y = 0; }
|
||||
if (width === undefined) { width = this.scene.sys.game.config.width; }
|
||||
if (height === undefined) { height = this.scene.sys.game.config.height; }
|
||||
if (thickness === undefined) { thickness = 64; }
|
||||
if (thickness === undefined) { thickness = 128; }
|
||||
if (left === undefined) { left = true; }
|
||||
if (right === undefined) { right = true; }
|
||||
if (top === undefined) { top = true; }
|
||||
|
|
|
@ -59,6 +59,7 @@ var Axes = require('../geometry/Axes');
|
|||
isStatic: false,
|
||||
isSleeping: false,
|
||||
ignoreGravity: false,
|
||||
ignorePointer: false,
|
||||
motion: 0,
|
||||
sleepThreshold: 60,
|
||||
density: 0.001,
|
||||
|
|
|
@ -176,7 +176,7 @@ var Body = require('./Body');
|
|||
* @return {composite} The original compositeA with the composite removed
|
||||
*/
|
||||
Composite.removeComposite = function(compositeA, compositeB, deep) {
|
||||
var position = Common.indexOf(compositeA.composites, compositeB);
|
||||
var position = compositeA.composites.indexOf(compositeB);
|
||||
if (position !== -1) {
|
||||
Composite.removeCompositeAt(compositeA, position);
|
||||
Composite.setModified(compositeA, true, true, false);
|
||||
|
@ -229,7 +229,7 @@ var Body = require('./Body');
|
|||
* @return {composite} The original composite with the body removed
|
||||
*/
|
||||
Composite.removeBody = function(composite, body, deep) {
|
||||
var position = Common.indexOf(composite.bodies, body);
|
||||
var position = composite.bodies.indexOf(body);
|
||||
if (position !== -1) {
|
||||
Composite.removeBodyAt(composite, position);
|
||||
Composite.setModified(composite, true, true, false);
|
||||
|
@ -282,7 +282,7 @@ var Body = require('./Body');
|
|||
* @return {composite} The original composite with the constraint removed
|
||||
*/
|
||||
Composite.removeConstraint = function(composite, constraint, deep) {
|
||||
var position = Common.indexOf(composite.constraints, constraint);
|
||||
var position = composite.constraints.indexOf(constraint);
|
||||
if (position !== -1) {
|
||||
Composite.removeConstraintAt(composite, position);
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ var Common = require('../core/Common');
|
|||
*/
|
||||
var _bucketRemoveBody = function(grid, bucket, body) {
|
||||
// remove from bucket
|
||||
bucket.splice(Common.indexOf(bucket, body), 1);
|
||||
bucket.splice(bucket.indexOf(body), 1);
|
||||
|
||||
// update pair counts
|
||||
for (var i = 0; i < bucket.length; i++) {
|
||||
|
|
|
@ -33,6 +33,7 @@ var Contact = require('./Contact');
|
|||
activeContacts: [],
|
||||
separation: 0,
|
||||
isActive: true,
|
||||
confirmedActive: true,
|
||||
isSensor: bodyA.isSensor || bodyB.isSensor,
|
||||
timeCreated: timestamp,
|
||||
timeUpdated: timestamp,
|
||||
|
|
|
@ -44,7 +44,6 @@ var Common = require('../core/Common');
|
|||
collisionStart = pairs.collisionStart,
|
||||
collisionEnd = pairs.collisionEnd,
|
||||
collisionActive = pairs.collisionActive,
|
||||
activePairIds = [],
|
||||
collision,
|
||||
pairId,
|
||||
pair,
|
||||
|
@ -55,12 +54,15 @@ var Common = require('../core/Common');
|
|||
collisionEnd.length = 0;
|
||||
collisionActive.length = 0;
|
||||
|
||||
for (i = 0; i < pairsList.length; i++) {
|
||||
pairsList[i].confirmedActive = false;
|
||||
}
|
||||
|
||||
for (i = 0; i < collisions.length; i++) {
|
||||
collision = collisions[i];
|
||||
|
||||
if (collision.collided) {
|
||||
pairId = Pair.id(collision.bodyA, collision.bodyB);
|
||||
activePairIds.push(pairId);
|
||||
|
||||
pair = pairsTable[pairId];
|
||||
|
||||
|
@ -76,6 +78,7 @@ var Common = require('../core/Common');
|
|||
|
||||
// update the pair
|
||||
Pair.update(pair, collision, timestamp);
|
||||
pair.confirmedActive = true;
|
||||
} else {
|
||||
// pair did not exist, create a new pair
|
||||
pair = Pair.create(collision, timestamp);
|
||||
|
@ -91,7 +94,7 @@ var Common = require('../core/Common');
|
|||
// deactivate previously active pairs that are now inactive
|
||||
for (i = 0; i < pairsList.length; i++) {
|
||||
pair = pairsList[i];
|
||||
if (pair.isActive && Common.indexOf(activePairIds, pair.id) === -1) {
|
||||
if (!pair.confirmedActive) {
|
||||
Pair.setActive(pair, false, timestamp);
|
||||
collisionEnd.push(pair);
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ module.exports = Common;
|
|||
* @return {boolean} True if the object is a string, otherwise false
|
||||
*/
|
||||
Common.isString = function(obj) {
|
||||
return toString.call(obj) === '[object String]';
|
||||
return Object.prototype.toString.call(obj) === '[object String]';
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -369,7 +369,6 @@ module.exports = Common;
|
|||
* @param {array} haystack
|
||||
* @param {object} needle
|
||||
* @return {number} The position of needle in haystack, otherwise -1.
|
||||
*/
|
||||
Common.indexOf = function(haystack, needle) {
|
||||
if (haystack.indexOf)
|
||||
return haystack.indexOf(needle);
|
||||
|
@ -381,6 +380,7 @@ module.exports = Common;
|
|||
|
||||
return -1;
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* A cross browser compatible array map implementation.
|
||||
|
|
Loading…
Reference in a new issue