我正在使用box2d创建具有不同形状的项目..我使用以下代码创建了一个正方形.b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(screenSize.width/2/PTM_RATIO,50/PTM_RATIO);
bodyDef.userData = sprite;
_sqrBody = world->CreateBody(&bodyDef);
// Define another box shape for our dynamic body.
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box
// Define the dynamic body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 10.0f;
fixtureDef.friction = 0.4f;
fixtureDef.restitution = 0.1f;
_sqrFixture = _sqrBody->CreateFixture(&fixtureDef);`
我想移动这个对象。我怎么能移动..“cctouches”中的任何代码。提前谢谢..
答案 0 :(得分:2)
body->setTransform(myposition, body->getAngle());
你可以在myposition中给出一个自定义位置