I've done quite a bit of searching and have found multiple suggestions for anti-gravity objects, but nothing seems to work just right. I have a physics world created with Earth's gravity. The user taps the screen and creates sprites/dynamic bodies. These then fall to the bottom of the screen due to the gravity. I have another sprite/body that is supposed to bounce around the screen, ignoring gravity and bouncing off the sprites that have been created. AndEngine's Box2D does not seem to have setGravityScale() so I can't set gravity to 0. The problem with creating fixtures attached to a kinematic body to determine which side is colliding is that the sprite is a circle (which isn't a big deal) and I don't quite understand how they work. I saw that I might be able to create a dynamic body with a constant force equal to body.getMass()*SensorManager.Earth in the -y direction and set the elasticity to 1, but there is no way to get a perfectly elastic collision. Anyone have any perfect suggestions?
相关问题
- What is wrong with my code PhysicsRemoveExample.ja
- Load Animation with Texture Packer in andengine
- Fast moving bodies miss the collision sometimes in
- Simulate the gravitational pull of a star?
- How to override onSetContentView while Using Ratio
相关文章
- AndEngine Sprite/Box2D Body removal crashes my pro
- Android Toast Messages not working
- Switching from AndEngine to libgdx - what to know?
- Setting of ImageView's gravity to the center i
- Center text android button
- andEngine Android-Studio linker Error during Build
- android remove gravity from accelerometer readings
- Unable to display game screen while admob integrat
The collisions in Box2D are never really elastic, there are some little errors in computations that tend to pile up and the body loses energy. There are two approaches that come to mind.
a) You can set the elasticity a little bit above 1
b) You can monitor the body's kinetic energy and if it drops below a certain threshold, give it a little nudge
JohnEye was correct, just not quite as informative as I liked. In a similar question, I answered this: How do I apply a force to a body in the direction it is traveling (Box2D)?