Is it possible to create a MatterJS Compound Body with each of the parts having it’s own sprite?
I tried using MatterJS’s render object on the compound body example to test but could not get the extra sprite to display.
function create ()
{
var Bodies = Phaser.Physics.Matter.Matter.Bodies;
var rectA = Bodies.rectangle(0, 0, 200, 24);
var rectB = Bodies.rectangle(0, 0, 24, 200);
var circleA = Bodies.circle(-100, 0, 24);
var circleB = Bodies.circle(100, 0, 24);
var circleC = Bodies.circle(0, -100, 24);
var circleD = Bodies.circle(0, 100, 24);
var test = Phaser.Physics.Matter.Matter.Body.create({
render: {
sprite: {
texture: 'assets/sprites/block.png'
}
}
})
var compoundBody = Phaser.Physics.Matter.Matter.Body.create({
parts: [ rectA, rectB, circleA, circleB, circleC, circleD, test ]
});
var block = this.matter.add.image(150, 0, 'block');
block.setExistingBody(compoundBody);
block.setFrictionAir(0.001).setBounce(0.9);
// A floor to land on
this.matter.add.image(350, 450, 'platform', null, { isStatic: true }).setScale(2, 0.5).setAngle(8);
}
Does Phaser utilize the render object on matterjs bodies at all? If so, is there a way to pass in a loaded sprite instead of having to use an image path?
Thanks!