BenSan Posted April 22, 2016 Share Posted April 22, 2016 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 More sharing options...
drhayes Posted April 22, 2016 Share Posted April 22, 2016 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 More sharing options...
BenSan Posted April 23, 2016 Author Share Posted April 23, 2016 Thank you @drhayes yes actually I wanted to scale the whole group. I just wasn't aware that it would stretch the image/sprite when I'd rotate it. But it makes sense, I'm guessing because it's non-uniformly scaled. Link to comment Share on other sites More sharing options...
BenSan Posted April 27, 2016 Author Share Posted April 27, 2016 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 More sharing options...
Recommended Posts