Creating a physics-based rope bridge
With the Box2D physics extension, creating complex physics-enabled elements is simple. One example of such a complex element is a rope bridge that reacts to collisions. In this recipe, we will see how to implement a method that creates a rope bridge tailored to specific parameters that control the bridge's size and physical properties.
Getting ready...
Create a new activity class named PhysicsBridgeActivity
that extends BaseGameActivity
.
How to do it...
Follow these steps to build our PhysicsBridgeActivity
activity class:
Place the following code in our activity to give us a standard AndEngine activity:
@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...