我移动一个带有箱体的球,并且在每次碰撞/接触时,我都会将线速度增加 1.1 倍。速度增加但我无法限制速度
代码:
public static final FixtureDef _BALL_FIXTURE_DEF=PhysicsFactory.createFixtureDef(0, 1.0f, 0.0f, false, _CATEGORYBIT_BALL, _MASKBITS_BALL, (short)0);
_ballCoreBody = PhysicsFactory.createCircleBody(_physicsWorld, _ballCore, BodyType.DynamicBody, _BALL_FIXTURE_DEF);
_ballCoreBody.setAngularDamping(0);
_ballCoreBody.setLinearDamping(0);
_ballCoreBody.setActive(true);
_ballCoreBody.setBullet(true);
_ballCoreBody.setGravityScale(0);
this._scene.attachChild(_ballCore);
this._physicsWorld.registerPhysicsConnector(new PhysicsConnector(_ballCore, _ballCoreBody));
内部联系人监听器
if(x1.getBody().getLinearVelocity().x<15.0f && x1.getBody().getLinearVelocity().y<15.0f)
x1.getBody().setLinearVelocity(new Vector2(x1.getBody().getLinearVelocity().x*1.2f, x1.getBody().getLinearVelocity().y*1.2f));
else
x1.getBody().setLinearVelocity(new Vector2(x1.getBody().getLinearVelocity().x/1.1f, x1.getBody().getLinearVelocity().y/1.1f));
我如何做到这一点?