Than I take a simple body and drop it in the gravity field. Starting from 0 speed it accelerating until reaches maximal speed
= SUPER_NUMBER*2;
Below there is the full code.
Moreover, using PhysicsWorld + FixedStepEngine this bug(?) gives the maximal body speed equal to 2*(frame rate).
private static final int CAMERA_WIDTH = 800;
private static final int CAMERA_HEIGHT = 480;
private BitmapTextureAtlas mBitmapTextureAtlas;
private TiledTextureRegion mBoxFaceTextureRegion;
private Scene mScene;
private PhysicsWorld mPhysicsWorld;
Camera camera;
@Override
public EngineOptions onCreateEngineOptions() {
camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
}
@Override
public void onCreateResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("");
this.mBitmapTextureAtlas = new BitmapTextureAtlas(64, 64,
TextureOptions.BILINEAR);
this.mBoxFaceTextureRegion = BitmapTextureAtlasTextureRegionFactory
.createTiledFromAsset(this.mBitmapTextureAtlas, this,
"face_box_tiled.png", 0, 0, 2, 1); // 64x32
this.mBitmapTextureAtlas.load(this.getTextureManager());
}
@Override
public Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mScene = new Scene();
this.mScene.setBackground(new Background(0, 0, 0));
this.mPhysicsWorld = new FixedStepPhysicsWorld(SUPER_NUMBER, new Vector2(0,
SensorManager.GRAVITY_EARTH), false, 3, 2);
this.mScene.registerUpdateHandler(this.mPhysicsWorld);
this.mScene.registerUpdateHandler(this);
final FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(1,
0.5f, 0.5f);
face = new AnimatedSprite(100, 100, this.mBoxFaceTextureRegion,
this.getVertexBufferObjectManager());
body = PhysicsFactory.createBoxBody(this.mPhysicsWorld, face,
BodyType.DynamicBody, objectFixtureDef);
face.animate(200);
this.mScene.attachChild(face);
this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face,
body, true, true));
camera.setChaseEntity(face);
return this.mScene;
}
AnimatedSprite face;
Body body;
private Vector2 v;
long t;
@Override
public void onUpdate(float pSecondsElapsed) {
// TODO Auto-generated method stubbody
if (System.currentTimeMillis() - t > 2000) {
t = System.currentTimeMillis();
v = body.getLinearVelocity();
Debug.e("linear speed Vx=" + v.x + " Vy=" + v.y);
}
}
@Override
public void reset() {
}