Physics.P2.Body#setRectangleFromSprite()

setRectangleFromSprite(sprite) → {p2.Rectangle}

Clears any previously set shapes.
Then creates a Rectangle shape sized to match the dimensions and orientation of the Sprite given.
If no Sprite is given it defaults to using the parent of this Body.
If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates.

Parameters
Name Type Argument Description
sprite Phaser.Sprite | Phaser.Image <optional>

The Sprite on which the Rectangle will get its dimensions.

Returns
p2.Rectangle -

The Rectangle shape that was added to the Body.

Source code: physics/p2/Body.js (Line 1252)
doc_phaser
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.