Firing objects from the catapult
You will now learn how to launch an object from the catapult. This will be accomplished by combining techniques into one smooth action, which you have already learned. Following are the steps:
The first step to firing an object from the catapult is to actually make an object.
Open SpriteBuilder and add a new node named
Brick
. Set bricks size to be (25
,25
) and its anchor point to be (0.5
,0.5
). Enable physics and set its density to a high value such as 50.0, and its friction to be 1.0, and its elasticity to 0.Add a color node to the node and give it an orange color to make it look more like a brick.
Publish and switch back to Xcode.
In order to fire an object, you will use the same techniques that you have already used. When the user touches down on the catapult arm, you will add a new object to it. You will then connect it to the arm with a pivot joint. Once the catapult is released, you will invalidate this joint and let the brick fly.
First modify the interface...