0
\$\begingroup\$

I have a box in Planck.js. I want to move this box with some keys. How can I do that? My code:

planck.testbed("boxworld", function(testbed) {
  var pl = planck,
    Vec2 = pl.Vec2;
  var world = new pl.World(Vec2(0, 0));

  //Box

  var box = world
    .createDynamicBody(Vec2(0.0, 10.0))
    .createFixture(pl.Box(0.5, 0.5), 20.0);
  box.render = { fill: "#FA8072", stroke: "black" };

  return world;
});

top down 8 direction movement

\$\endgroup\$
0
\$\begingroup\$

You could set velocity for the box, apply force or directly change location.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.