Yes, I understand that this is a physics engine. That's why I wonder if anyone has gone a step further to create a gamelib where the physics is one component, amongst e.g. pathfinding etc.
Anyways this is my first shot:
This works great for the positioning, but the rotation is off. Any ideas?
Anyways this is my first shot:
Quote:
//======================
// Draw DisplayObject
//======================
public function DrawDisplayObject(bb:b2Body):void{
// get actor
var dispObj:DisplayObject = DisplayObject(bb.m_userData);
if(dispObj==null){return;}
// add actor if needed
if(!m_sprite.getChildByName(dispObj.name)){
m_sprite.addChild(dispObj);
}
// position actor
dispObj.x = bb.m_position.x * m_physScale;
dispObj.y = bb.m_position.y * m_physScale;
dispObj.rotation = bb.m_rotation;
}
// Draw DisplayObject
//======================
public function DrawDisplayObject(bb:b2Body):void{
// get actor
var dispObj:DisplayObject = DisplayObject(bb.m_userData);
if(dispObj==null){return;}
// add actor if needed
if(!m_sprite.getChildByName(dispObj.name)){
m_sprite.addChild(dispObj);
}
// position actor
dispObj.x = bb.m_position.x * m_physScale;
dispObj.y = bb.m_position.y * m_physScale;
dispObj.rotation = bb.m_rotation;
}
This works great for the positioning, but the rotation is off. Any ideas?