jurbank Posted September 17, 2018 Share Posted September 17, 2018 I'm trying to make a game where the user can drag parts to attach to the Ship. The main challenge I'm running into is attaching the bodies into a single, fixed group so when the player thrusts around with the arrow keys, the other bodies stay in-place. I was looking into composites but I'm not sure how to use them in Phaser, looks pretty straight forward in standard MatterJS. I was also playing with constraints and joints but those seem to attach at one point between both bodies. I also tried adding two constrains, one at each edge but it seemed like the 2nd overwrote the 1st. Any thoughts? Here's my code playground - https://codepen.io/jurbank/pen/Mqqyow?editors=0011 Link to comment Share on other sites More sharing options...
iKest Posted September 18, 2018 Share Posted September 18, 2018 use containers. Link to comment Share on other sites More sharing options...
jurbank Posted September 18, 2018 Author Share Posted September 18, 2018 Thanks! I actually was starting down that route....found this example the other night - http://labs.phaser.io/edit.html?src=src\game objects\container\matter physics body test.js Seems to work fine with creating image objects using the Factory class (this.add.image(...)) However, when I extend a new MatterImage and instantiate it, the x,y context appear agnostic to the parent container context and results in duplicate boxes. Here's a short animation - https://www.useloom.com/share/57dbd41477684e73b87201aec803fbce Link to comment Share on other sites More sharing options...
jurbank Posted September 18, 2018 Author Share Posted September 18, 2018 The factory created instance doesn't have the 'world' property, where as the extended Image object of (Phaser.Physics.Matter.Image) does. Perhaps that is the issue? Link to comment Share on other sites More sharing options...
iKest Posted September 18, 2018 Share Posted September 18, 2018 matter.world have this instance inside localWorld property Link to comment Share on other sites More sharing options...
jurbank Posted September 19, 2018 Author Share Posted September 19, 2018 @iKest I'm seeing the bodies in the local world so I'm not sure how to apply your recommendation. Here's my Codepen: Editor view - https://codepen.io/jurbank/project/editor/AmPBBN Render view - https://codepen.io/jurbank/project/live/AmPBBN/ Link to comment Share on other sites More sharing options...
Recommended Posts