mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
Add getState and setState
This commit is contained in:
@@ -112,6 +112,14 @@ float Body::getAngularVelocity() const
|
||||
return body->GetAngularVelocity();
|
||||
}
|
||||
|
||||
void Body::getState(b2Vec2 &pos_o, float &a_o, b2Vec2 &vel_o, float &da_o) const
|
||||
{
|
||||
pos_o = Physics::scaleUp(body->GetPosition());
|
||||
a_o = body->GetAngle();
|
||||
vel_o = Physics::scaleUp(body->GetLinearVelocity());
|
||||
da_o = body->GetAngularVelocity();
|
||||
}
|
||||
|
||||
float Body::getMass() const
|
||||
{
|
||||
return body->GetMass();
|
||||
@@ -225,6 +233,13 @@ void Body::setAngularVelocity(float r)
|
||||
body->SetAngularVelocity(r);
|
||||
}
|
||||
|
||||
void Body::setState(b2Vec2 pos, float a, b2Vec2 vel, float da)
|
||||
{
|
||||
body->SetTransform(Physics::scaleDown(pos), a);
|
||||
body->SetLinearVelocity(Physics::scaleDown(vel));
|
||||
body->SetAngularVelocity(da);
|
||||
}
|
||||
|
||||
void Body::setPosition(float x, float y)
|
||||
{
|
||||
body->SetTransform(Physics::scaleDown(b2Vec2(x, y)), body->GetAngle());
|
||||
|
||||
Reference in New Issue
Block a user