Skip to content

Commit 497fa1f

Browse files
committed
Added copyFromArray method
1 parent ef79edf commit 497fa1f

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ There is a new Game Object Component called `TextureCrop`. It replaces the Textu
122122
* `Rectangle.Intersection` will take two Rectangle objects and return the area of intersection between them. If there is no intersection, an empty Rectangle is returned.
123123
* `Pointer.prevPosition` is a new Vector2 that stores the previous position of the Pointer, prior to the most recent DOM event. You can use this when performing calculations between the old and current positions, such as for tracking the pointer speed.
124124
* `Pointer.getInterpolatedPosition` is a new method that will return an array of smoothly interpolated values between the old and previous position of the Pointer. You can configure how many interpolation steps should take place (the default is 10) and provide an output array to store them in. This method is handy if you've got an object tracking a pointer and you want to ensure it has smooth movement (as the DOM will often process pointer events at a faster rate than the game loop can update).
125+
* `TransformMatrix.copyFromArray` will populate a matrix from the given array of values. Where 0, 1, 2, 3, 4 and 5 map to a, b, c, d, e and f.
125126

126127
### Updates
127128

src/gameobjects/components/TransformMatrix.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,31 @@ var TransformMatrix = new Class({
596596
return this;
597597
},
598598

599+
/**
600+
* Set the values of this Matrix to copy those of the array given.
601+
* Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f.
602+
*
603+
* @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray
604+
* @since 3.11.0
605+
*
606+
* @param {array} src - The array of values to set into this matrix.
607+
*
608+
* @return {this} This TransformMatrix.
609+
*/
610+
copyFromArray: function (src)
611+
{
612+
var matrix = this.matrix;
613+
614+
matrix[0] = src[0];
615+
matrix[1] = src[1];
616+
matrix[2] = src[2];
617+
matrix[3] = src[3];
618+
matrix[4] = src[4];
619+
matrix[5] = src[5];
620+
621+
return this;
622+
},
623+
599624
/**
600625
* Set the values of this Matrix.
601626
*

0 commit comments

Comments
 (0)