简体   繁体   English

Andengine,我如何保持球弹起相同高度?

[英]Andengine, how do i keep a ball bouncing the same height?

I'm trying to keep a ball bouncing the same height each time it bounces like doodle jump. 我试图使每次反弹时都保持相同高度的球像涂鸦跳跃一样反弹。 but when the ball reaches the platform it decelerates to an inch each bounce and slowly gains speed. 但是,当球到达平台时,每次反弹都会减速到一英寸,并逐渐提高速度。 My question is how to keep its height permanent no matter what it bounces on. 我的问题是无论反弹到什么高度,如何保持其高度永久不变。 This is my ball and platform(the platform is in the sky) http://imgur.com/WIyfRJ7 here are my physics for my platform and ball 这是我的球和平台(平台在空中) http://imgur.com/WIyfRJ7这是我的球和平台的物理原理

final FixtureDef PLAYER_FIX = PhysicsFactory.createFixtureDef(10.0f, 1.2f, 0.0f);
    body = PhysicsFactory.createCircleBody(physicsWorld, sPlayer, BodyType.DynamicBody, PLAYER_FIX );


final FixtureDef PLATFORM_FIX = PhysicsFactory.createFixtureDef(10.0f, 0.85f, 0.0f);
    PlatformBody = PhysicsFactory.createBoxBody(physicsWorld, Platform, BodyType.KinematicBody, PLATFORM_FIX);

To bounce the ball at the same height, do the following 要以相同的高度反弹球,请执行以下操作

The value of restitution varies between 0 and 1. 1 means the ball's velocity will be exactly reflected and 0 means it won't bounce. 恢复的值在0到1之间变化。1表示将精确反映球的速度,0表示不会反弹。

Set the fixture's restitution to 1.0f 将灯具的恢复设置为1.0f

For more details you can refer to http://www.box2d.org/manual.html 有关更多详细信息,请参阅http://www.box2d.org/manual.html

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM