Issue with resetting physics body after scaling/resizing of objects

Hi,

I’ve been stuck for a while on this…I am having an issue apply/resetting the physics body after the display object has been scaled/resized. Ideally, I would prefer that the physics objects automatically take into account changes in display objects. But it seems like it does not…I tried doing it manually through some hacks but everything I try is crashing. Is this even possible with the current Corona SDK?

Thanks,

  • John [import]uid: 35190 topic_id: 8123 reply_id: 308123[/import]

Hey John,

The docs for physics say something about ‘…not to use scaling on the bodies, it won’t work…’ :
http://developer.anscamobile.com/content/game-edition-physics-bodies#physics.addBody

I wound up using TexturePacker and Physics editor to create my hd and sd sprites. I created the physics bodies off of the sd sprites, and when the HD images are scaled down, they match up.

I added a check to see if the display.constantScaleX was <1… if it was, then i forced the sprites to be scaled at 50%… somehow it all worked after a bit of trial and error.

I don’t think that you can scale the object at all after that… the physics body will stay the same size.
[import]uid: 135765 topic_id: 8123 reply_id: 96223[/import]

Currently removing the body and adding it again is your best option for this, IMHO.

http://developer.anscamobile.com/reference/index/physicsremovebody

Peach :slight_smile: [import]uid: 52491 topic_id: 8123 reply_id: 96257[/import]

I tried this and this works, but for some reason, my sprite spazzes out when I use this method (compared to acting normally when I don’t). Does anyone know why this may be the case?

I tried this and this works, but for some reason, my sprite spazzes out when I use this method (compared to acting normally when I don’t). Does anyone know why this may be the case?