0

我在 physicworld 中有一个未在 touchArea 注册的精灵,它仅在与其他精灵碰撞时移动并在 physicworld 边界上定期反弹。现在我也尝试在没有碰撞时随机移动它。我试图给它一个线速度,但它一直移动到右下角并停留在那里而不会反弹

if(Sprite.getX() > 0) {
    bodySprite.setLinearVelocity(new Vector2(VELOCITY_X, VELOCITY_Y));
} else if(Sprite.getX() + Sprite.getWidth() > CAMERA_WIDTH) {
    bodySprite.setLinearVelocity(new Vector2(-VELOCITY_X, -VELOCITY_X));
}
4

1 回答 1

0

你绝对确定这Sprite.getX() + Sprite.getWidth() > CAMERA_WIDTH是真的吗?(考虑到轮换等...)

我宁愿在屏幕边缘放置某种 box2d 传感器,当它们开始触摸时,施加一个脉冲。

于 2013-06-03T17:51:41.187 回答