Joining two objects
I have given you examples of how to use forces and impulses to move physics objects around, but I haven't covered joints yet. Joints are used to join two objects together so that the distance between them is the same. We will make a bridge using joints, so, create a new layout and make it look like the one shown in the following screenshot:
The sprites for the bridge and the fence objects are located under the Tiles
folder. Before continuing, check the bridge's collision polygon and fix it so that no lines will intersect each other, just like the buttonBlue
object. You want to be careful when adding physics objects, as small sprites tend to have similar collision polygons.
Tip
Always look for collision polygons when adding an object you want to make a physics object, especially the ones with small sprites.
The fences and bridges are physics objects, but only the fences are immovable; the bridges are still movable, but we won't let them fall to the bottom. We will tie the...