Jump to content

PIXI + Matter.js MouseConstraints


yurqo
 Share

Recommended Posts

I'm new to Matter.js, trying to make  air hokey game and don't understand how to use Matter's MouseConstraint with pixi. It works fine if your canvas element and physics world are the same size (https://codepen.io/celsowhite/pen/XWbEzpx), but what if not and you have some PIXI.Container instead? I need player to be able to move the striker while having impact on the puck, which depends on striker's inertia, that's why just changing the position of body in Matter world won't work. While it's probably not hard to take care of creating and destroying Constraints in Matter world according to local coords in mouse input events, maybe there's more simple and natural way of making them work together? 

Link to comment
Share on other sites

7 hours ago, yurqo said:

I'm new to Matter.js, trying to make  air hokey game and don't understand how to use Matter's MouseConstraint with pixi. It works fine if your canvas element and physics world are the same size (https://codepen.io/celsowhite/pen/XWbEzpx), but what if not and you have some PIXI.Container instead? I need player to be able to move the striker while having impact on the puck, which depends on striker's inertia, that's why just changing the position of body in Matter world won't work. While it's probably not hard to take care of creating and destroying Constraints in Matter world according to local coords in mouse input events, maybe there's more simple and natural way of making them work together? 

I would recommend not using mousecontraints etc from matter, just the matter physics, if you want your game to have physics, add them to matterjs as required (as bodies or whatever) and calculate the constraints yourself.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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