Henryk

size of physics body, when scaled

Recommended Posts

I have an sprite on the stage in ME, which I scaled down by half.

Then I applied physics and changed the body size, making it wider, so it can collide with the worldBounds to my liking. I used the physics tool to enable the highlighting of my physics body to do so.

 

However, it looks good visually, but is too small for the collision. If I change it to the double size, which looks wrong within ME, it collides the way it should.

 

I can imagine, this has to do with the way phaser handles this.

Neverteheless maybe a little hint on the tutorial site (http://mightyfingers.com/tutorials/physics/change-body-size/) could help others.

 

Or is there a way I'm not aware of? I'm intending to scale up the sprite during the game gradually, so I would have to recalculate the physics body width every time, would I?

 

best, Henryk

Share this post


Link to post
Share on other sites

Actually you found a bug in the MightyEditor - it should take scale in count - while showing physics bounds - as Phaser scales physics body automatically when sprite has been scaled.

 

If you want to prevent body from scaling:

var box = mt.create("box");var pd = box.mt.data.physics.size;box.body.setSize(pd.width/box.scale.x, pd.height/box.scale.y, pd.offsetX, pd.offsetY);

you should set size every time you scale sprite..

probably there are a flag - or easier way - but I couldn't find in the docs.

 

won't hurt to ask on general phaser forum.

 

 

I'll fix so visual display of a body will scale with the sprite with the next ME update - planned this week.

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.