mirror of
https://github.com/wassname/phaser.git
synced 2026-07-15 01:11:26 +08:00
Phaser.AnimationParser now sets the trimmed data directly for Pixi Texture frames. Tested across JSON Hash, JSON Data, Sprite Sheet and XML.
This commit is contained in:
@@ -153,10 +153,14 @@ Phaser.AnimationParser = {
|
||||
frames[i].spriteSourceSize.h
|
||||
);
|
||||
|
||||
// We had to hack Pixi to get this to work :(
|
||||
PIXI.TextureCache[uuid].trimmed = true;
|
||||
PIXI.TextureCache[uuid].trim.x = frames[i].spriteSourceSize.x;
|
||||
PIXI.TextureCache[uuid].trim.y = frames[i].spriteSourceSize.y;
|
||||
|
||||
PIXI.TextureCache[uuid].trim = {
|
||||
x: frames[i].spriteSourceSize.x,
|
||||
y: frames[i].spriteSourceSize.y,
|
||||
realWidth: frames[i].sourceSize.w,
|
||||
realHeight: frames[i].sourceSize.h
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -225,10 +229,14 @@ Phaser.AnimationParser = {
|
||||
frames[key].spriteSourceSize.h
|
||||
);
|
||||
|
||||
// We had to hack Pixi to get this to work :(
|
||||
PIXI.TextureCache[uuid].trimmed = true;
|
||||
PIXI.TextureCache[uuid].trim.x = frames[key].spriteSourceSize.x;
|
||||
PIXI.TextureCache[uuid].trim.y = frames[key].spriteSourceSize.y;
|
||||
|
||||
PIXI.TextureCache[uuid].trim = {
|
||||
x: frames[i].spriteSourceSize.x,
|
||||
y: frames[i].spriteSourceSize.y,
|
||||
realWidth: frames[i].sourceSize.w,
|
||||
realHeight: frames[i].sourceSize.h
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -313,10 +321,14 @@ Phaser.AnimationParser = {
|
||||
|
||||
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 = frameX;
|
||||
PIXI.TextureCache[uuid].trim.y = frameY;
|
||||
|
||||
PIXI.TextureCache[uuid].trim = {
|
||||
x: frameX,
|
||||
y: frameY,
|
||||
realWidth: width,
|
||||
realHeight: height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-12
@@ -248,21 +248,12 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
|
||||
|
||||
if (this.game.transparent === false)
|
||||
{
|
||||
if (this.game.renderType == Phaser.CANVAS)
|
||||
if (typeof color === 'string')
|
||||
{
|
||||
// Set it directly, this allows us to use rgb alpha values in Canvas mode.
|
||||
this.game.canvas.style.backgroundColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof color === 'string')
|
||||
{
|
||||
color = Phaser.Color.hexToRGB(color);
|
||||
}
|
||||
|
||||
this._stage.setBackgroundColor(color);
|
||||
color = Phaser.Color.hexToRGB(color);
|
||||
}
|
||||
|
||||
this._stage.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,8 +90,6 @@ Phaser.Image = function (game, x, y, key, frame) {
|
||||
*/
|
||||
this.fixedToCamera = false;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
Phaser.Image.prototype = Object.create(PIXI.Sprite.prototype);
|
||||
@@ -185,6 +183,7 @@ Phaser.Image.prototype.loadTexture = function (key, frame) {
|
||||
if (key instanceof Phaser.RenderTexture)
|
||||
{
|
||||
this.game.cache.getTextureFrame(key.name).clone(this.currentFrame);
|
||||
// WOKWOKSK
|
||||
}
|
||||
else if (key instanceof Phaser.BitmapData)
|
||||
{
|
||||
@@ -241,7 +240,8 @@ Phaser.Image.prototype.loadTexture = function (key, frame) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Crop allows you to crop the texture used to display this Image. Cropping takes place from the top-left of the Image and can be modified in real-time.
|
||||
* Crop allows you to crop the texture used to display this Image.
|
||||
* Cropping takes place from the top-left of the Image and can be modified in real-time by providing an updated rectangle object.
|
||||
*
|
||||
* @method Phaser.Image#crop
|
||||
* @memberof Phaser.Image
|
||||
|
||||
+16
-3
@@ -745,19 +745,32 @@ Phaser.Utils.Debug.prototype = {
|
||||
* @method Phaser.Utils.Debug#renderRectangle
|
||||
* @param {Phaser.Rectangle} rect - The Rectangle to render.
|
||||
* @param {string} [color] - Color of the debug info to be rendered (format is css color string).
|
||||
* @param {boolean} [filled=true] - Render the rectangle as a fillRect (default, true) or a strokeRect (false)
|
||||
*/
|
||||
renderRectangle: function (rect, color) {
|
||||
renderRectangle: function (rect, color, filled) {
|
||||
|
||||
if (this.context == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof filled === 'undefined') { filled = true; }
|
||||
|
||||
color = color || 'rgba(0,255,0,0.3)';
|
||||
|
||||
this.start();
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
|
||||
|
||||
if (filled)
|
||||
{
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.context.strokeStyle = color;
|
||||
this.context.strokeRect(rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
|
||||
this.stop();
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user