mirror of https://github.com/axmolengine/axmol.git
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:
parent
44fb4ba3bc
commit
af503f4a65
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue