Jump to content

Phaser Scaling Bug?


Recommended Posts

I'm trying to do something very simple and getting all kinds of frustrating and weird behaviors. 
All I'm doing is adding a graphics object as a child to a sprite and the scaling is all screwed up.

For example, if I instantiate this object

class Test extends Phaser.Sprite {    graphics : Phaser.Graphics;    constructor(game : CustomGame, x = 0, y = 0, width = 500, height = 10) {        super(game, x, y);        game.world.addChild(this);        this.width = width;        this.height = height;        this.graphics = new Phaser.Graphics(game, 0, 0);        this.graphics.boundsPadding = 0;        this.graphics.beginFill()            .drawRect(0, 0, this.width, this.height)            .endFill()        this.addChild(this.graphics);    }}

The rendered graphic will be ~3px high instead of the supplied 10px value. When I check the sprite's `this.scale`, the values are something like { x: 15, y: 0.3 } even though I've never touched it.
All I'm doing in this test case is to instantiate this one object, no other game related code is running. If I initialize this graphic as a child of the world it renders correctly. Does anyone know why this could be happening?

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...