O'Reilly logo

Cocos2D Game Development Essentials by Ben Trengrove

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dragging an object against a spring joint

In order to drag our catapult arm back, we will create another joint. However, this joint will be between our finger and the catapult arm. As you can't create a joint to your finger, what you will do is create another empty node that will move based on touch. This empty node will be joined to the catapult arm. Following are the steps:

  1. Create a new empty node as in the last section. Enable physics and set it to static. The position of the node does not matter as it will be moved in code, but you must ensure that it is a child of the physics node. Add a code connection called _touchNode to the new node.
  2. You will also need a code connection for the catapult arm. Call it _catapultArm.
  3. Add another code connection ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required