Creating a physics-based moving platform
Most platform-style games have some sort of moving platform, which challenges the player to land with accurate timing. From a developer's standpoint, the platform is simply a physics-enabled body that moves from one location to another. In this recipe, we will see how to create a horizontally-moving platform.
Getting ready...
Create a new activity class named MovingPhysicsPlatformActivity
that extends BaseGameActivity
.
How to do it...
Follow these steps to build our MovingPhysicsPlatformActivity
activity class:
Insert the following code snippet into our activity to make it functional:
@Override public Engine onCreateEngine(final EngineOptions pEngineOptions) { return new FixedStepEngine(pEngineOptions, 60); } @Override public EngineOptions onCreateEngineOptions() { return new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new FillResolutionPolicy(), new Camera(0, 0, 800, 480) ).setWakeLockOptions(WakeLockOptions.SCREEN_ON...