AdrianoLobo Posted April 1, 2018 Share Posted April 1, 2018 Hi, I want to create this module, it's composed with 4 connectors and a main module. I created each using the: this.scene.matter.add.sprite I would like to be able to batch them togheter and simply call: module.setPosition(x, y) to move all of it. It would me nice too (but not required) if I was able to batch multiple modules to create a space station and be able to move everything. I Tried with Matter Compound Bodies, but it seams that it can only compound matterjs pure bodies, not those with sprites attached to it. * I followed this example: http://labs.phaser.io/edit.html?src=src\game objects\tilemap\collision\matter platformer with wall jumping.js I saw the new container feature but I dont know if it supports physics objects nor I was able to test it with the container branch. Can you guys help me pointing to a direction? Link to comment Share on other sites More sharing options...
Martin Pabst Posted August 31, 2018 Share Posted August 31, 2018 You can add matter.js bodies to phaser containers in phaser 3 this way: let container = scene.add.container(x, y); let matterEnabledContainer = scene.matter.add.gameObject(this.container); let matterBody = ... // setup matter.js-body matterEnabledContainer.setExistingBody(matterBody); Link to comment Share on other sites More sharing options...
JustMike Posted May 11, 2020 Share Posted May 11, 2020 (edited) mpoundBody = Body.create({ parts: [mainBody, this.sensors.bottom, this.sensors.left, this.sensors.right], frictionStatic: 0, frictionAir: 0.02, friction: 0.1 }); this.sprite .setExistingBody(compoundBody) .setScale(2) .setFixedRotation() // Sets inertia to infinity so the player can't rotate .setPosition(x, y); } based on the turoial - when I try to setExistingBody(compoundBody) I get this error Argument of type 'Body' is not assignable to parameter of type 'BodyType'. Type 'Body' is missing the following properties from type 'BodyType': positionImpulse, previousPositionImpulse, constraintImpulse, totalContacts, and 10 more.ts(2345) Edited May 14, 2020 by samme format Link to comment Share on other sites More sharing options...
Recommended Posts