Gleda
Gleda

Reputation: 31

How to rotate fixed object using PhysicsJS?

I'm learning new javascript lib PhysicsJS (link).

If anybody can help me or show me example of:

How to rotate fixed object (like propeller and balls bounce of it)?

How to set in world some object that bounce with object that not bounce?

Edge-collision-detection (AABB) , Is it possible to do a circle instead of the cube?

Upvotes: 3

Views: 1042

Answers (2)

trubachev.artem
trubachev.artem

Reputation: 11

You can rotate objects by changing angular property like this:

world.on('step', function(){
  barrel.state.angular.pos += 0.02;
  world.render();
});

Upvotes: 1

Jasper
Jasper

Reputation: 1193

Your question about rotating a "fixed" object was asked in another post: PhysicsJS - how to create a body which rotates about a fixed point when struck?

As for setting some objects that bounce and some that don't: This can't be done yet. It's being worked out as part of future development: https://github.com/wellcaffeinated/PhysicsJS/issues/30

For edge collision detection, right now it's only possible to use rectangles. You would have to modify the edge collision detection code to make it a circle.

Upvotes: 0

Related Questions