Jump to content

Sprite bodies not following sprite angle


4ucai
 Share

Recommended Posts

game.add.tween(ship).to({ angle: 110 }, 1000, Phaser.Easing.Quadratic.InOut, true, 500);

I rotated the sprite in the above example but the body doesn't follow. Can be seen with the code below

game.debug.renderSpriteBody(battleShip);

Is this fixed in the latest 1.07?

Link to comment
Share on other sites

Hi rich,

 

This is the original angle. I did game.debug.renderSpriteBody(); to check their bounding area.

q2.png

 

 

When I rotated the 1st ship, the body did not rotate together with the sprite. The collision works but I would like the 1st ship front to collide.

 

q1.png

Link to comment
Share on other sites

Yes, this is expected behaviour. As I said the sprite bodies are fixed to AABB (axis-aligned bounding boxes) only. You can adjust the offset of them and the size of them, but they won't rotate in an AABB system. For that you need a more advanced physics system (like Chipmunk or Box2D) or wait for us to finish our own version, but this is months away yet really.

Link to comment
Share on other sites

  • 6 months later...

Sorry to bring up this old post, but this is exactly what I am working on right now. I understand that Phaser's arcade physics uses AABB, and that can't be rotated. That makes sense and is fine. However, it would be great if there was a way to get a new bounding box of that rotated sprite. For example, getting something similar to the red box for my purposes:

 

6LQ3UA8.png

 

The rotated white box is what we can't have in the arcade system, but can we get the red box to be used as a sprite's body shape?

 

Note: The screenshot not from Phaser, just another similar project I was working on.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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