Jump to content

MatterJS, Help with composites


Recommended Posts

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


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...