Reputation: 834
I have the following code to manually set the position of a (dynamic) object in a Box2D world (drawn with the help of EaselJS).
Unfortunately setTransform
returns this error.
Uncaught TypeError: Cannot read property 'position' of undefined
This is the code
// during drag and drop
if(mouseJoint & isMouseDown) {
mouseJoint.SetTarget(new b2Vec2(mouseX, mouseY));
var body = mouse.getBodyAtMouse();
if(body != null) {
body.SetAngularVelocity(0);
body.SetAngle(0);
body.SetTransform(b2Vec2(10,10), 0);
}
...
Upvotes: 0
Views: 853
Reputation: 8272
I'm no JS guru, but I suspect you need to use 'new b2Vec2' instead of just 'b2Vec2', in the same way as you have for the SetTarget call.
Upvotes: 0