Jump to content

Group scale & body scale


Teflo
 Share

Recommended Posts

Hey there, great framework you made!

But I have one problem. When I scale a group, every sprite gets rescaled, but the bodies attached to them are not. So I tried to scale the bodies with body.updateBounds(); But that didn't change anything. So I took a look in the code and I see, the updateBounds() method doesn't take the group scale into account, but just the sprite scale, which isn't directly affected by group scale.

 

Now I tried to copy the updateBounds() method and edit it, so it uses the scale I want. It seems to be working at first, but somewhere the body size is resetted and I end up with same unscaled bodies.

 

 

How am I supposed to do it correctly?
And just because I'm curious: Is there a good way to let everything be normal and just render the whole thing with a scale?

 

Thanks!

Link to comment
Share on other sites

  • 1 year later...

I'm having the same issue.

 

I have a parent group that contains sprite objects with arcade physics bodies enabled on them. When I set the parent group scale, the sprite scale correctly, but their bodies remain at the size they were at creation.

 

Anyone found any solutions?

Link to comment
Share on other sites

for arcade you could do this maybe.. but it does seem like a bit of a workaround for something you'd expect to happen internally.

group.forEach(function(sprite) {      sprite.body.setSize(sprite.width * group.scale.x,  sprite.height * group.scale.y)})

although I have some odd collision behaviour here http://phaser.io/sandbox/XzaIExTz/play

 

(scale 2,2 worked ok though)

Link to comment
Share on other sites

Yeah, this is essentially what I ended up doing. Luckily, I'm not getting the same collision problems as the example you posted. It's not pretty (especially as I continue to add objects since I'm scaling for zoom functionality), but it works!

Link to comment
Share on other sites

  • 5 months later...
 Share

  • Recently Browsing   0 members

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