@Override public Scene onLoadScene() { final Scene scene = new Scene(2, true, 4, (COUNT_VERTICAL - 1) * (COUNT_HORIZONTAL - 1)); scene.setBackground(new ColorBackground(0, 0, 0)); scene.setOnSceneTouchListener(this); this.mPhysicsWorld = new PhysicsWorld( new Vector2( 0, 2 * SensorManager.GRAVITY_EARTH / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT), false); final Shape ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2); final Shape roof = new Rectangle(0, 0, CAMERA_WIDTH, 2); final Shape left = new Rectangle(0, 0, 2, CAMERA_HEIGHT); final Shape right = new Rectangle(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT); final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f); PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody(this.mPhysicsWorld, roof, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.StaticBody, wallFixtureDef); PhysicsFactory.createBoxBody(this.mPhysicsWorld, right, BodyType.StaticBody, wallFixtureDef); scene.getBottomLayer().addEntity(ground); scene.getBottomLayer().addEntity(roof); scene.getBottomLayer().addEntity(left); scene.getBottomLayer().addEntity(right); for (int x = 1; x < COUNT_HORIZONTAL; x++) { for (int y = 1; y < COUNT_VERTICAL; y++) { final float pX = (((float) CAMERA_WIDTH) / COUNT_HORIZONTAL) * x + y; final float pY = (((float) CAMERA_HEIGHT) / COUNT_VERTICAL) * y; this.addFace(scene, pX - 16, pY - 16); } } scene.registerUpdateHandler( new TimerHandler( 2, new ITimerCallback() { @Override public void onTimePassed(final TimerHandler pTimerHandler) { scene.unregisterUpdateHandler(pTimerHandler); scene.registerUpdateHandler(PhysicsBenchmark.this.mPhysicsWorld); scene.registerUpdateHandler( new TimerHandler( 10, new ITimerCallback() { @Override public void onTimePassed(TimerHandler pTimerHandler) { PhysicsBenchmark.this.mPhysicsWorld.setGravity( new Vector2( 0, -SensorManager.GRAVITY_EARTH / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT)); } })); } })); return scene; }