2012-09-26 22 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()')」,我應該通過什麼作爲第二個參數? –