1

I'd like to know if there's a way to get and set the scale of a physicsjs body and have the bitmap assigned to the view of the body scale with it. I see no reference to scale in the state or geometry objects, and trying to set the width or height has no effect.

I'd like to increase the scale of a body and the bitmap assigned to its view.

isherwood
  • 58,414
  • 16
  • 114
  • 157
Ribs
  • 1,449
  • 2
  • 13
  • 27

1 Answers1

0

If you change the geometry on a body then you must then recalculate to get the change to take in the physics: https://github.com/wellcaffeinated/PhysicsJS/wiki/Bodies#recalculating

Additionally, if you're using the Pixi renderer or one of the other builtins, you will have to set the body's view to undefined to have it update on the graphics side as well: http://wellcaffeinated.net/PhysicsJS/docs/#Body-prototype-view

So for a specific body in the simulation someBody which has a radius which isn't 20 already,

someBody.geometry.radius = 20;
someBody.view = undefined;
someBody.recalc();

Hope this answers your question.

  • Setting the body's view to undefined removes the bitmap I have as the body's background. I can resize the body with your suggestion, but not without losing the bitmap. Any way to have the bitmap being used as the view retained and scaled? updating my question to include keeping a bitmap intact. – Ribs Dec 15 '14 at 21:11
  • Could you include the code you use for setting the view? – Jade Bilkey Dec 15 '14 at 21:20