Allow velocity to be applied to Chipmunk's kinematic bodies (#17094)

* Allow velocity to be applied to Chipmunk's kinematic bodies

* Added check for CP_BODY_TYPE_STATIC

Thanks to @minggo for the code review
This commit is contained in:
Wilson E. Alvarez 2017-01-05 22:35:34 -03:00 committed by minggo
parent 44fb4ba3bc
commit af503f4a65
1 changed files with 6 additions and 6 deletions

View File

@ -575,12 +575,12 @@ void PhysicsBody::addMoment(float moment)
void PhysicsBody::setVelocity(const Vec2& velocity)
{
if (!_dynamic)
if (cpBodyGetType(_cpBody) == CP_BODY_TYPE_STATIC)
{
CCLOG("physics warning: your can't set velocity for a static body.");
CCLOG("physics warning: you can't set velocity for a static body.");
return;
}
cpBodySetVelocity(_cpBody, PhysicsHelper::point2cpv(velocity));
}
@ -601,12 +601,12 @@ Vec2 PhysicsBody::getVelocityAtWorldPoint(const Vec2& point)
void PhysicsBody::setAngularVelocity(float velocity)
{
if (!_dynamic)
if (cpBodyGetType(_cpBody) == CP_BODY_TYPE_STATIC)
{
CCLOG("physics warning: your can't set angular velocity for a static body.");
CCLOG("physics warning: you can't set angular velocity for a static body.");
return;
}
cpBodySetAngularVelocity(_cpBody, velocity);
}