Hi,
I add a sprite to the stage and want to give him physics. It works, but the box2d body is not on the same place then the sprite!!
why??
regards
I add a sprite to the stage and want to give him physics. It works, but the box2d body is not on the same place then the sprite!!
why??
regards
Code:
private function addCircle(tShape:Sprite, tX:Number, tY:Number):void
{
var tDynamicBody:b2Body;
var tCircle:b2CircleDef = new b2CircleDef();
tCircle.radius = (tShape.width/2)/pPhysScale;
tCircle.density = 1;
tCircle.friction = 0.3;
tCircle.restitution = 0.2
var tMyBodyDef:b2BodyDef = new b2BodyDef();
tMyBodyDef.position.Set(tShape.x / pPhysScale, tShape.y / pPhysScale);
tDynamicBody = pWorld.CreateBody(tMyBodyDef);
tDynamicBody.CreateShape(tCircle);
tDynamicBody.SetMassFromShapes();
pActor = new Actor(tDynamicBody, tShape);
tDynamicBody.m_userData = pActor;
pActors.push(pActor);
drawArea.addChild(tShape);
}
{
var tDynamicBody:b2Body;
var tCircle:b2CircleDef = new b2CircleDef();
tCircle.radius = (tShape.width/2)/pPhysScale;
tCircle.density = 1;
tCircle.friction = 0.3;
tCircle.restitution = 0.2
var tMyBodyDef:b2BodyDef = new b2BodyDef();
tMyBodyDef.position.Set(tShape.x / pPhysScale, tShape.y / pPhysScale);
tDynamicBody = pWorld.CreateBody(tMyBodyDef);
tDynamicBody.CreateShape(tCircle);
tDynamicBody.SetMassFromShapes();
pActor = new Actor(tDynamicBody, tShape);
tDynamicBody.m_userData = pActor;
pActors.push(pActor);
drawArea.addChild(tShape);
}