mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 07:04:31 +00:00
Tidy up TransformerTile.
And make it extend TransformerImage for concision.
This commit is contained in:
parent
abace16646
commit
8e8b15841a
1 changed files with 4 additions and 138 deletions
|
@ -4,10 +4,8 @@
|
|||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
||||
*/
|
||||
|
||||
var TransformMatrix = require('../../../../gameobjects/components/TransformMatrix.js');
|
||||
var Class = require('../../../../utils/Class');
|
||||
var Merge = require('../../../../utils/object/Merge');
|
||||
var RenderNode = require('../RenderNode');
|
||||
var TransformerImage = require('./TransformerImage');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
|
@ -17,57 +15,16 @@ var RenderNode = require('../RenderNode');
|
|||
* @memberof Phaser.Renderer.WebGL.RenderNodes
|
||||
* @constructor
|
||||
* @since 3.90.0
|
||||
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
||||
* @extends Phaser.Renderer.WebGL.RenderNodes.TransformerImage
|
||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||
* @param {object} [config] - The configuration object for this RenderNode.
|
||||
*/
|
||||
var TransformerTile = new Class({
|
||||
Extends: RenderNode,
|
||||
Extends: TransformerImage,
|
||||
|
||||
initialize: function TransformerTile (manager, config)
|
||||
{
|
||||
config = Merge(config || {}, this.defaultConfig);
|
||||
|
||||
RenderNode.call(this, config.name, manager);
|
||||
|
||||
/**
|
||||
* The matrix used to store the final quad data for rendering.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.RenderNodes.TransformerTile#quad
|
||||
* @type {Float32Array}
|
||||
* @since 3.90.0
|
||||
*/
|
||||
this.quad = new Float32Array(8);
|
||||
|
||||
/**
|
||||
* The matrix used internally to compute camera transforms.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.RenderNodes.TransformerTile#_camMatrix
|
||||
* @type {Phaser.GameObjects.Components.TransformMatrix}
|
||||
* @since 3.90.0
|
||||
* @private
|
||||
*/
|
||||
this._camMatrix = new TransformMatrix();
|
||||
|
||||
/**
|
||||
* The matrix used internally to compute sprite transforms.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.RenderNodes.TransformerTile#_spriteMatrix
|
||||
* @type {Phaser.GameObjects.Components.TransformMatrix}
|
||||
* @since 3.90.0
|
||||
* @private
|
||||
*/
|
||||
this._spriteMatrix = new TransformMatrix();
|
||||
|
||||
/**
|
||||
* The matrix used internally to compute the final transform.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.RenderNodes.TransformerTile#_calcMatrix
|
||||
* @type {Phaser.GameObjects.Components.TransformMatrix}
|
||||
* @since 3.90.0
|
||||
* @private
|
||||
*/
|
||||
this._calcMatrix = new TransformMatrix();
|
||||
TransformerImage.call(this, manager, config);
|
||||
},
|
||||
|
||||
defaultConfig: {
|
||||
|
@ -90,13 +47,6 @@ var TransformerTile = new Class({
|
|||
{
|
||||
this.onRunBegin(drawingContext);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var camera = drawingContext.camera;
|
||||
var calcMatrix = this._calcMatrix;
|
||||
var spriteMatrix = this._spriteMatrix;
|
||||
|
@ -164,90 +114,6 @@ var TransformerTile = new Class({
|
|||
this.quad
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
var frame = texturerNode.frame;
|
||||
var uvSource = texturerNode.uvSource;
|
||||
|
||||
var frameX = uvSource.x;
|
||||
var frameY = uvSource.y;
|
||||
|
||||
var displayOriginX = gameObject.displayOriginX;
|
||||
var displayOriginY = gameObject.displayOriginY;
|
||||
|
||||
var x = -displayOriginX + frameX;
|
||||
var y = -displayOriginY + frameY;
|
||||
|
||||
var customPivot = frame.customPivot;
|
||||
|
||||
var flipX = 1;
|
||||
var flipY = 1;
|
||||
|
||||
if (gameObject.flipX)
|
||||
{
|
||||
if (!customPivot)
|
||||
{
|
||||
x += (-frame.realWidth + (displayOriginX * 2));
|
||||
}
|
||||
|
||||
flipX = -1;
|
||||
}
|
||||
|
||||
if (gameObject.flipY)
|
||||
{
|
||||
if (!customPivot)
|
||||
{
|
||||
y += (-frame.realHeight + (displayOriginY * 2));
|
||||
}
|
||||
|
||||
flipY = -1;
|
||||
}
|
||||
|
||||
var gx = gameObject.x;
|
||||
var gy = gameObject.y;
|
||||
|
||||
var camera = drawingContext.camera;
|
||||
var calcMatrix = this._calcMatrix;
|
||||
var camMatrix = this._camMatrix;
|
||||
var spriteMatrix = this._spriteMatrix;
|
||||
|
||||
spriteMatrix.applyITRS(gx, gy, gameObject.rotation, gameObject.scaleX * flipX, gameObject.scaleY * flipY);
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
// Multiply the camera by the parent matrix
|
||||
camMatrix.copyFrom(camera.matrix);
|
||||
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * gameObject.scrollFactorX, -camera.scrollY * gameObject.scrollFactorY);
|
||||
|
||||
// Undo the camera scroll
|
||||
spriteMatrix.e = gx;
|
||||
spriteMatrix.f = gy;
|
||||
}
|
||||
else
|
||||
{
|
||||
// camMatrix will not be mutated after this point, so we just take a reference.
|
||||
camMatrix = camera.matrix;
|
||||
spriteMatrix.e -= camera.scrollX * gameObject.scrollFactorX;
|
||||
spriteMatrix.f -= camera.scrollY * gameObject.scrollFactorY;
|
||||
}
|
||||
|
||||
// Multiply by the Sprite matrix, store result in calcMatrix
|
||||
camMatrix.multiply(spriteMatrix, calcMatrix);
|
||||
|
||||
// Store the output quad.
|
||||
calcMatrix.setQuad(
|
||||
x,
|
||||
y,
|
||||
x + texturerNode.frameWidth,
|
||||
y + texturerNode.frameHeight,
|
||||
false,
|
||||
this.quad
|
||||
);
|
||||
*/
|
||||
this.onRunEnd(drawingContext);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue