Multiple Anims update, Tilemap fixes and some new examples.

This commit is contained in:
photonstorm
2013-10-31 15:45:19 +00:00
parent 712858cf75
commit 6f93a2ec94
24 changed files with 876 additions and 335 deletions
+40 -34
View File
@@ -259,55 +259,61 @@ Phaser.AnimationParser = {
var data = new Phaser.FrameData();
var frames = xml.getElementsByTagName('SubTexture');
var newFrame;
var uuid;
var frame;
var x;
var y;
var width;
var height;
var frameX;
var frameY;
var frameWidth;
var frameHeight;
for (var i = 0; i < frames.length; i++)
{
var uuid = game.rnd.uuid();
uuid = game.rnd.uuid();
var frame = frames[i].attributes;
frame = frames[i].attributes;
newFrame = data.addFrame(new Phaser.Frame(
i,
frame.x.nodeValue,
frame.y.nodeValue,
frame.width.nodeValue,
frame.height.nodeValue,
frame.name.nodeValue,
uuid
));
name = frame.name.nodeValue;
x = parseInt(frame.x.nodeValue);
y = parseInt(frame.y.nodeValue);
width = parseInt(frame.width.nodeValue);
height = parseInt(frame.height.nodeValue);
frameX = null;
frameY = null;
if (frame.frameX)
{
frameX = Math.abs(parseInt(frame.frameX.nodeValue));
frameY = Math.abs(parseInt(frame.frameY.nodeValue));
frameWidth = parseInt(frame.frameWidth.nodeValue);
frameHeight = parseInt(frame.frameHeight.nodeValue);
}
newFrame = data.addFrame(new Phaser.Frame(i, x, y, width, height, name, uuid));
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], {
x: frame.x.nodeValue,
y: frame.y.nodeValue,
width: frame.width.nodeValue,
height: frame.height.nodeValue
x: x,
y: y,
width: width,
height: height
});
// Trimmed?
if (frame.frameX.nodeValue != '-0' || frame.frameY.nodeValue != '-0')
if (frameX !== null || frameY !== null)
{
newFrame.setTrim(
true,
frame.width.nodeValue,
frame.height.nodeValue,
Math.abs(frame.frameX.nodeValue),
Math.abs(frame.frameY.nodeValue),
frame.frameWidth.nodeValue,
frame.frameHeight.nodeValue
);
newFrame.setTrim(true, width, height, frameX, frameY, frameWidth, frameHeight);
PIXI.TextureCache[uuid].realSize = {
x: Math.abs(frame.frameX.nodeValue),
y: Math.abs(frame.frameY.nodeValue),
w: frame.frameWidth.nodeValue,
h: frame.frameHeight.nodeValue
};
PIXI.TextureCache[uuid].realSize = { x: frameX, y: frameY, w: frameWidth, h: frameHeight };
// We had to hack Pixi to get this to work :(
PIXI.TextureCache[uuid].trimmed = true;
PIXI.TextureCache[uuid].trim.x = Math.abs(frame.frameX.nodeValue);
PIXI.TextureCache[uuid].trim.y = Math.abs(frame.frameY.nodeValue);
PIXI.TextureCache[uuid].trim.x = frameX;
PIXI.TextureCache[uuid].trim.y = frameY;
}
}
+10 -6
View File
@@ -864,14 +864,15 @@ Phaser.Physics.Arcade.prototype = {
this._overlap = 0;
// The hulls overlap, let's process it
this._maxOverlap = body.deltaAbsX() + this.OVERLAP_BIAS;
// this._maxOverlap = body.deltaAbsX() + this.OVERLAP_BIAS;
if (body.deltaX() < 0)
{
// Moving left
this._overlap = tile.right - body.hullX.x;
if ((this._overlap > this._maxOverlap) || body.allowCollision.left == false || tile.tile.collideRight == false)
// if ((this._overlap > this._maxOverlap) || body.allowCollision.left == false || tile.tile.collideRight == false)
if (body.allowCollision.left == false || tile.tile.collideRight == false)
{
this._overlap = 0;
}
@@ -885,7 +886,8 @@ Phaser.Physics.Arcade.prototype = {
// Moving right
this._overlap = body.hullX.right - tile.x;
if ((this._overlap > this._maxOverlap) || body.allowCollision.right == false || tile.tile.collideLeft == false)
// if ((this._overlap > this._maxOverlap) || body.allowCollision.right == false || tile.tile.collideLeft == false)
if (body.allowCollision.right == false || tile.tile.collideLeft == false)
{
this._overlap = 0;
}
@@ -948,14 +950,15 @@ Phaser.Physics.Arcade.prototype = {
this._overlap = 0;
// The hulls overlap, let's process it
this._maxOverlap = body.deltaAbsY() + this.OVERLAP_BIAS;
// this._maxOverlap = body.deltaAbsY() + this.OVERLAP_BIAS;
if (body.deltaY() < 0)
{
// Moving up
this._overlap = tile.bottom - body.hullY.y;
if ((this._overlap > this._maxOverlap) || body.allowCollision.up == false || tile.tile.collideDown == false)
// if ((this._overlap > this._maxOverlap) || body.allowCollision.up == false || tile.tile.collideDown == false)
if (body.allowCollision.up == false || tile.tile.collideDown == false)
{
this._overlap = 0;
}
@@ -969,7 +972,8 @@ Phaser.Physics.Arcade.prototype = {
// Moving down
this._overlap = body.hullY.bottom - tile.y;
if ((this._overlap > this._maxOverlap) || body.allowCollision.down == false || tile.tile.collideUp == false)
// if ((this._overlap > this._maxOverlap) || body.allowCollision.down == false || tile.tile.collideUp == false)
if (body.allowCollision.down == false || tile.tile.collideUp == false)
{
this._overlap = 0;
}