Zbyszeq
Zbyszeq

Reputation: 1

FlxG.overlap doesen't work correctly when changing angle of an object

FlxG.overlap won't work correctly when I change the angle of an object. The object's hitbox is still where it would have been if it wasn't angled. I don't know how to fix that.

I tried updating the sprite's hitbox and changing the angle before adding the sprite, yet the sprite's hitbox stayed as its angle would have been 0.

Upvotes: 0

Views: 110

Answers (1)

Adam Harte
Adam Harte

Reputation: 10530

FlxG.overlap uses a simple bounding box test (AABB) to check for overlap and ignores rotation.

If you want to test for overlap of rotated sprites, then you can use FlxG.pixelPerfectOverlap. But it can be much slower that overlap, so be a little careful. It tests the actual pixels of each sprite, so can also be used for odd shaped graphics that use alpha.

Upvotes: 1

Related Questions