Creating a rope
Though it is performance-intensive to simulate a realistic rope using Box2D, a simple rope is not only fast, but also very customizable. A rope, from a construction standpoint, is similar to a rag doll and can add an extra layer of playability to a game. If a physics simulation seems to be too bland to attract players, the addition of rope will be sure to give players another reason to like a game. In this recipe, we will create a physics-enabled rope for use in our simulations.
Getting ready...
Review the creation of a physics-based activity in the Introduction to the Box2D physics extension recipe, the creation of bodies in the Understanding different body types recipe, and the use of revolute joints and mouse joints in the Working with joints recipe, all found in this chapter.
How to do it...
Refer to the supplemental Rope
and RopeActivity
classes for the code that we use in this recipe.
How it works...
A rope created in Box2D can be thought of as a chain of similar bodies linked...