Jump to content

Stretching of rotated sprite when parent group width and height set


BenSan
 Share

Recommended Posts

When width and height is set of a group, and a child sprite within is rotated, then said sprite gets stretched.
Is this intended behaviour?

I'm using Chrome ( Version 52.0.2712.0 canary ) on Windows with Phaser 2.4.6

Example: http://phaser.io/sandbox/zGrSberY/play

function create() {
    var sizedGroup = game.add.group();
    sprite = sizedGroup.create(0, 0, 'phaser');
    sizedGroup.width  = 100;
    sizedGroup.height = 100;
    
    sizedGroup.x = 200;
    sizedGroup.y = 200;
}

function update(){
    sprite.angle += 0.6;
}

 

Link to comment
Share on other sites

I've never set the width or height of a group before. What are you trying to do by doing that?

Here's a quote from the documentation for Phaser.Group#width:

Quote

The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set

So, this effect is intentional. Setting the group width scales the group.

Link to comment
Share on other sites

A solution in case any one else has this problem:

It works with nested groups. Just resize the child group and it won't scale the sprite when rotating. -> http://phaser.io/sandbox/TMaGcVgL/play

function create() {
    var parentGroup = game.add.group();
    var childGroup = game.add.group();
    
    parentGroup.add(childGroup);
    
    var sprite = childGroup.create(0, 0, 'phaser');
    
    childGroup.width  = 100;
    childGroup.height = 300;
    
    parentGroup.x = 400;
    parentGroup.y = 200;
}

function update() {
    childGroup.angle += 0.5;
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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