schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Adding a sprite image to a collision body and adding physics when it reaches center canvas #271

Open courtneyvigo opened 7 years ago

courtneyvigo commented 7 years ago

Hi all :) Im new to p2 and pixi. Im combining the two. I currently have a pixi sprite that is an image of a gem that moves across the canvas. Once it reaches center screen (250px), it will use p2 to make it fall into a cup, along with other objects that collide with each other.

currently, the code making the image is: color = new PIXI.Sprite(resources["https://res.cloudinary.com/dubyisimd/image/upload/v1481228417/red_f5iwah.png"].texture);

What is the correct way to link the pixi sprite to the physics engine?

Thank you!

jtenner commented 7 years ago

There is already a project that combines these two technologies specifically.

Located at phaser.io.

This should solve your use case.

Cheers, -Josh