Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d Game Development Essentials

You're reading from   Cocos2d Game Development Essentials For new users - a quickstart guide to bringing your mobile game ideas to life with Cocos2D

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher
ISBN-13 9781784390327
Length 136 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ben Trengrove Ben Trengrove
Author Profile Icon Ben Trengrove
Ben Trengrove
Arrow right icon
View More author details
Toc

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:

  1. The first step to firing an object from the catapult is to actually make an object.

  2. 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.

  3. Add a color node to the node and give it an orange color to make it look more like a brick.

  4. Publish and switch back to Xcode.

  5. 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.

  6. First modify the interface...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image