2012-09-26 21 views
0

我有以下代码来手动设置Box2D世界中(动态)对象的位置(借助EaselJS绘制)。 不幸的是setTransform返回此错误。Box2D&EaselJS,setTransform返回一个错误

Uncaught TypeError: Cannot read property 'position' of undefined 

这是代码

// 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); 
    } 

    ... 

回答

1

解决使用

body.SetPosition(new b2Vec2(10,10)); 
0

我不是JS大师,但我怀疑你需要,你必须使用,而不是仅仅“b2Vec2”新b2Vec2“,以同样的方式用于SetTarget调用。

+0

真!我现在得到“'未定义'不是一个函数(评估'a.GetAngle()')”,我应该通过什么作为第二个参数? –