mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Added e and f properties and multiplyWithOffset and copyFrom
This commit is contained in:
parent
8a7ead03a8
commit
cf008e612c
2 changed files with 112 additions and 0 deletions
|
@ -85,6 +85,8 @@ The Tint component documentation has been overhauled to explain these difference
|
|||
* `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 (thanks @jjalonso)
|
||||
* `Tileset.glTexture` is a new property that maps to the WebGL Texture for the Tileset image. It's used internally by the renderer to avoid expensive object look-ups and is set automatically in the `Tileset.setImage` method.
|
||||
* `Frame.glTexture` is a new property that maps to the WebGL Texture for the Frames Texture Source image. It's used internally by the renderer to avoid expensive object look-ups and is set automatically in the `Frame` constructor.
|
||||
* `TransforMatrix.multiplyWithOffset` is a new method that will multiply the given matrix with the current one, factoring in an additional offset to the results. This is used internally by the renderer code in various places.
|
||||
* `TransforMatrix.e` and `TransforMatrix.f` are two new properties that are an alias for the `tx` and `ty` values.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -152,6 +152,48 @@ var TransformMatrix = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The Translate X value.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.TransformMatrix#e
|
||||
* @type {number}
|
||||
* @since 3.11.0
|
||||
*/
|
||||
e: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.matrix[4];
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this.matrix[4] = value;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The Translate Y value.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.TransformMatrix#f
|
||||
* @type {number}
|
||||
* @since 3.11.0
|
||||
*/
|
||||
f: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.matrix[5];
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this.matrix[5] = value;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The Translate X value.
|
||||
*
|
||||
|
@ -476,6 +518,74 @@ var TransformMatrix = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the values of this Matrix to copy those of the matrix given.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.TransformMatrix#copyFrom
|
||||
* @since 3.11.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from.
|
||||
*
|
||||
* @return {this} This TransformMatrix.
|
||||
*/
|
||||
copyFrom: function (src)
|
||||
{
|
||||
var matrix = this.matrix;
|
||||
|
||||
matrix[0] = src.a;
|
||||
matrix[1] = src.b;
|
||||
matrix[2] = src.c;
|
||||
matrix[3] = src.d;
|
||||
matrix[4] = src.tx;
|
||||
matrix[5] = src.ty;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the values of this Matrix to copy those of the matrix given.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset
|
||||
* @since 3.11.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from.
|
||||
* @param {number} offsetX - Horizontal offset to factor in to the multiplication.
|
||||
* @param {number} offsetY - Vertical offset to factor in to the multiplication.
|
||||
*
|
||||
* @return {this} This TransformMatrix.
|
||||
*/
|
||||
multiplyWithOffset: function (src, offsetX, offsetY)
|
||||
{
|
||||
var matrix = this.matrix;
|
||||
var otherMatrix = src.matrix;
|
||||
|
||||
var a0 = matrix[0];
|
||||
var b0 = matrix[1];
|
||||
var c0 = matrix[2];
|
||||
var d0 = matrix[3];
|
||||
var tx0 = matrix[4];
|
||||
var ty0 = matrix[5];
|
||||
|
||||
var pse = offsetX * a0 + offsetY * c0 + tx0;
|
||||
var psf = offsetX * b0 + offsetY * d0 + ty0;
|
||||
|
||||
var a1 = otherMatrix[0];
|
||||
var b1 = otherMatrix[1];
|
||||
var c1 = otherMatrix[2];
|
||||
var d1 = otherMatrix[3];
|
||||
var tx1 = otherMatrix[4];
|
||||
var ty1 = otherMatrix[5];
|
||||
|
||||
matrix[0] = a1 * a0 + b1 * c0;
|
||||
matrix[1] = a1 * b0 + b1 * d0;
|
||||
matrix[2] = c1 * a0 + d1 * c0;
|
||||
matrix[3] = c1 * b0 + d1 * d0;
|
||||
matrix[4] = tx1 * a0 + ty1 * c0 + pse;
|
||||
matrix[5] = tx1 * b0 + ty1 * d0 + psf;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the values of this Matrix.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue