Skip to content

scaleX then scaleY lead to matterjs shape error #4206

@YannCaron

Description

@YannCaron

Version

  • Phaser Version: 3.15.1

  • Operating system: ubuntu

  • Browser: All

Description

When a Matter.Image, configured with a physic shape, is scaled on X then on Y or vice versa, the shape become distorted.
It seems that the second scale apply again the first one.

class Actor extends Phaser.Physics.Matter.Image {
    constructor(scene, x, y, texture) {
    super(scene.matter.world, x, y, texture, 0, {
        shape: scene.fixtures[texture]
    });

    // ....

}

let gem = new Actor(this, 100, 400, 'Gem Blue');
gem.scaleX = 0.5;
// here everything is ok
gem.scaleY = 0.5;
// here the shape x is resized again

give that (with debug mode activated) :

  • With scaleX = 0.5 then scaleY = 0.5
    image

  • With scaleY=0.5 then scaleX = 0.5
    image

turn around

Use setScale(0.5, 0.5) instead.

words

Many thanks to Phaser and matterjs teams that give us so valuable tools.
Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions