mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
In Matter.js if you scaled a Body it would only scale correctly once, due to the way Matter handles scaling internally. We now automatically reset the Matter scale before applying the new value, which allows you to keep the Phaser and Matter object scales in sync. Fix #3785 #3951
This commit is contained in:
parent
ae01830a5e
commit
a98b3c3b15
2 changed files with 15 additions and 0 deletions
|
@ -149,6 +149,7 @@ The Tile Sprite Game Object has been given an internal overhaul to make it more
|
|||
* The calls to `DistanceBetween` have been replaced with `DistanceSquared` in the `closest` and `furthest` functions within Arcade Physics (thanks @Mursaat)
|
||||
* The RandomDataGenerator will now create a default random seed if you instantiate your own version of the class (instead of using `Phaser.Math.RND`) and don't provide a seed for it (thanks michaeld)
|
||||
* The Tilemap `createFromObjects` method will now add custom properties to the Game Objects. It works by checking if the property exists or not, and if not, it sets it in the Game Objects Data Manager (thanks @scalemailted @samme)
|
||||
* In Matter.js if you scaled a Body it would only scale correctly once, due to the way Matter handles scaling internally. We now automatically reset the Matter scale before applying the new value, which allows you to keep the Phaser and Matter object scales in sync. Fix #3785 #3951 (thanks @bergben)
|
||||
|
||||
### Game Config Resolution Specific Bug Fixes
|
||||
|
||||
|
|
|
@ -84,6 +84,8 @@ var Transform = {
|
|||
|
||||
set: function (value)
|
||||
{
|
||||
var factor = 1 / this._scaleX;
|
||||
|
||||
this._scaleX = value;
|
||||
|
||||
if (this._scaleX === 0)
|
||||
|
@ -95,6 +97,9 @@ var Transform = {
|
|||
this.renderFlags |= _FLAG;
|
||||
}
|
||||
|
||||
// Reset Matter scale back to 1 (sigh)
|
||||
Body.scale(this.body, factor, this._scaleY);
|
||||
|
||||
Body.scale(this.body, value, this._scaleY);
|
||||
}
|
||||
|
||||
|
@ -116,6 +121,8 @@ var Transform = {
|
|||
|
||||
set: function (value)
|
||||
{
|
||||
var factor = 1 / this._scaleY;
|
||||
|
||||
this._scaleY = value;
|
||||
|
||||
if (this._scaleY === 0)
|
||||
|
@ -127,6 +134,8 @@ var Transform = {
|
|||
this.renderFlags |= _FLAG;
|
||||
}
|
||||
|
||||
Body.scale(this.body, this._scaleX, factor);
|
||||
|
||||
Body.scale(this.body, this._scaleX, value);
|
||||
}
|
||||
|
||||
|
@ -273,9 +282,14 @@ var Transform = {
|
|||
if (x === undefined) { x = 1; }
|
||||
if (y === undefined) { y = x; }
|
||||
|
||||
var factorX = 1 / this._scaleX;
|
||||
var factorY = 1 / this._scaleY;
|
||||
|
||||
this._scaleX = x;
|
||||
this._scaleY = y;
|
||||
|
||||
Body.scale(this.body, factorX, factorY, point);
|
||||
|
||||
Body.scale(this.body, x, y, point);
|
||||
|
||||
return this;
|
||||
|
|
Loading…
Reference in a new issue