BenSan

Stretching of rotated sprite when parent group width and height set

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;
}

 

Share this post


Link to post
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.

Share this post


Link to post
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;
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.