Skip to content

Commit

Permalink
Fixed incompatibility with Phaser 2.4.9/2.5.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
hexus committed Jun 26, 2016
1 parent 2afae11 commit 86c6886
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "phaser-arcade-slopes",
"version": "0.1.0",
"version": "0.1.1-dev",
"description": "A Phaser plugin that provides sloped tiles for the Arcade Physics engine.",
"main": "dist/phaser-arcade-slopes.js",
"scripts": {},
Expand Down
2 changes: 1 addition & 1 deletion src/ArcadeSlopes.js
Expand Up @@ -58,7 +58,7 @@ Phaser.Plugin.ArcadeSlopes.prototype.constructor = Phaser.Plugin.ArcadeSlopes;
* @constant
* @type {string}
*/
Phaser.Plugin.ArcadeSlopes.VERSION = '0.1.0-beta';
Phaser.Plugin.ArcadeSlopes.VERSION = '0.1.1-dev';

/**
* The Separating Axis Theorem collision solver type.
Expand Down
14 changes: 8 additions & 6 deletions src/ArcadeSlopes/Overrides.js
Expand Up @@ -20,13 +20,14 @@ Phaser.Plugin.ArcadeSlopes.Overrides = {};
* @param {integer} i - The tile index.
* @param {Phaser.Sprite} sprite - The sprite to check.
* @param {Phaser.Tile} tile - The tile to check.
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemap layer the tile belongs to.
* @param {function} collideCallback - An optional collision callback.
* @param {function} processCallback - An optional overlap processing callback.
* @param {object} callbackContext - The context in which to run the callbacks.
* @param {boolean} overlapOnly - Whether to only check for an overlap.
* @return {boolean} - Whether a collision occurred.
*/
Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile = function (i, sprite, tile, collideCallback, processCallback, callbackContext, overlapOnly) {
Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile = function (i, sprite, tile, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) {
if (!sprite.body) {
return false;
}
Expand All @@ -41,7 +42,7 @@ Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile = function (i, sprite,

return true;
}
} else if (this.separateTile(i, sprite.body, tile, overlapOnly)) {
} else if (this.separateTile(i, sprite.body, tile, tilemapLayer, overlapOnly)) {
this._total++;

if (collideCallback) {
Expand All @@ -60,13 +61,14 @@ Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTile = function (i, sprite,
* @method Phaser.Plugin.ArcadeSlopes.Overrides#collideSpriteVsTiles
* @param {Phaser.Sprite} sprite - The sprite to check.
* @param {Phaser.Tile[]} tiles - The tiles to check.
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemap layer the tiles belong to.
* @param {function} collideCallback - An optional collision callback.
* @param {function} processCallback - An optional overlap processing callback.
* @param {object} callbackContext - The context in which to run the callbacks.
* @param {boolean} overlapOnly - Whether to only check for an overlap.
* @return {boolean} - Whether a collision occurred.
*/
Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles = function (sprite, tiles, collideCallback, processCallback, callbackContext, overlapOnly) {
Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles = function (sprite, tiles, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) {
var collided = false;

if (!sprite.body) {
Expand All @@ -76,10 +78,10 @@ Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTiles = function (sprite, ti
for (var i = 0; i < tiles.length; i++) {
if (processCallback) {
if (processCallback.call(callbackContext, sprite, tiles[i])) {
collided = this.collideSpriteVsTile(i, sprite, tiles[i], collideCallback, processCallback, callbackContext, overlapOnly) || collided;
collided = this.collideSpriteVsTile(i, sprite, tiles[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) || collided;
}
} else {
collided = this.collideSpriteVsTile(i, sprite, tiles[i], collideCallback, processCallback, callbackContext, overlapOnly) || collided;
collided = this.collideSpriteVsTile(i, sprite, tiles[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) || collided;
}
}

Expand Down Expand Up @@ -119,7 +121,7 @@ Phaser.Plugin.ArcadeSlopes.Overrides.collideSpriteVsTilemapLayer = function (spr
return false;
}

var collided = this.collideSpriteVsTiles(sprite, tiles, collideCallback, processCallback, callbackContext, overlapOnly);
var collided = this.collideSpriteVsTiles(sprite, tiles, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly);

if (!collided && !overlapOnly) {
// TODO: This call is too hacky and solver-specific
Expand Down

0 comments on commit 86c6886

Please sign in to comment.