Hi all,
I’ve just started playing around with Phaser 3, and I’m having trouble adjusting a sprite’s collision box. I’m rotating entities, so I have to use the Matter engine (which sucks, as approximately 100% of the examples use Arcade)
My code’s a mess (I’m still in the can I do this? phase), but basically I have:
Preload
this.load.spritesheet(
'ship',
'assets/ship.png',
{
frameWidth:100,
frameHeight:208
}
);
The “ship” is a 2 frame sprite - frame 1 has just the ship, frame 2 has the ship with exhaust. I’m trying to adjust the collision box so the exhaust portion of the sprite doesn’t collide with anything.
Create
window.player = this.matter.add.sprite(
this.cameras.main.width/4,
this.cameras.main.height/2,
'ship'
)
// this moves the rotation point to the middle of the ship
// instead of the middle of the sprite
.setOrigin(0.5,0.2);
// I thought this should do it, but the pink box doesn't change
window.player.setSize(200,200);
How do I change the collision box? I know I can change the initial frame height when loading the sprite sheet, but that clips off the exhaust.
Here’s a screenshot of what I have, without the exhaust: https://imgur.com/a/kWHntCU. I’d like the pink pox to be snug to the ship, but allow the exhaust to still be seen.
Any other tips would also be helpful. Documentation on Phaser 3 + Matter.js seems pretty non-existent.