when i load player character in Phaser.js using matter physics there’s a extra margin. Is there a way to remove it using Phaser.js or i will need to update the image directly.
If you just want to change the size, because of physics collisions, you can simply use the function setSize of the Body object. (link to the documentation)
And with setOffset you can move the collision box, to the correct position. (link to the documentation)
2
Answers
thanks to winner_joiner, for the help
For Arcade phisics
To crop the hit box of a sprite you can use the
player.body.setSize(10,10);
orplayer.body.setOffset(5, 0);
For Matter phisics
Use
setBody({width:10, height:10})
, orsetRectangle
Final result
using
setBody({width:10, height:10})
If you just want to change the size, because of physics collisions, you can simply use the function
setSize
of theBody
object. (link to the documentation)And with
setOffset
you can move the collision box, to the correct position.(link to the documentation)