0

I have a dynamic body in name and want to make its x position follow the mouse, is this possible.

player = new Body(BodyType.DYNAMIC);
        player.shapes.add(new Polygon(Polygon.rect(400, 350, 100, 150)));
        player.shapes.add(new Polygon(Polygon.rect(435, 450, 20, 150)));
        player.shapes.add(new Polygon(Polygon.rect(380, 600, 150, 20)));
        player_mc = new MovieClip(Assets.tb.getTextures("player"));
        player.userData.graphic = player_mc;
        player.space = space;
        addChild(player.userData.graphic);
LeBlaireau
  • 17,133
  • 33
  • 112
  • 192

1 Answers1

3

The suggested way would be to use a constraint.

See how it is done in the FixedDragging sample: http://napephys.com/samples.html#swf-FixedDragging (View source with .as/.hx tabs at top)

deltaluca
  • 1,652
  • 2
  • 10
  • 9