Tag Archive for 'physics'

Learning Cocos2D Book Now In Print!

Learning Cocos2D Book

Hi everyone, this is Ray Wenderlich and Rod Strougo.

We are pleased to announce that our book Learning Cocos2D: A Hands-On Guide to Building iOS Games with Cocos2D, Box2D, and Chipmunk is now in print!

The book teaches you everything you need to know to use Cocos2D and the Box2D and Chipmunk physics libraries to build your own games. It’s great for complete beginners to Cocos2D/Box2D/Chipmunk, or for those who are looking to firm up their knowledge or learn some new tricks.

The book takes a hands-on approach, and walks you step-by-step through the process of building a complete game called Space Viking! After building this game, you’ll have practical experience you can apply to making your own games.

By making the complete game you’ll learn the following:

  • How to move a character with Joystick controls
  • How to animate characters with multiple animations and states
  • How to add enemies with basic AI
  • How to make side-scrolling levels
  • How to make a cool cart racing game with realistic game physics
  • How to make a jumping platformer with game physics
  • And much more!
Learn how to make a cool game with Cocos2D, Box2D, and Chipmunk!

Learn how to make a cool game with Cocos2D, Box2D, and Chipmunk!

If you want to see more, click here to see a video of one of the levels in action!

The code in the book is compatible with the latest version of Xcode (Xcode 4) and Cocos2D (Cocos2D 1.0).

You can get the book in the following formats:

Each format contains the same content – it’s just where you’d prefer to read it.

Rod and I would like to give a huge thanks to Ricardo Quesada, Erin Catto, Scott Lembcke – without these guys, this book (and many cool games!) would never have been possible!

We hope you enjoy the book, and if you have any comments or questions please stop by the book’s official website or the book forums!

A SpaceManager Game

This article is going to build upon the basics described in the previous SpaceManager article written some time ago which can be found here: http://www.cocos2d-iphone.org/archives/677

About the Author:

My name is Rob, I’m one of the guys working under the mobile bros. LLC title. We’ve released a few games in the recent years, all using SpaceManager, including: Pachingo, Trundle, and Kill Timmy. I am personally interested in physics myself and always looking for new ways to incorporate them in our games.

Goals

Today’s goal is to design a basic game using Cocos2d, Chipmunk, and SpaceManager. I believe the best lessons are those learned from example, so for this article I’ll walk you through building a small example of a game and show off some of the features of SpaceManager. Some of the things we’ll demonstrate here are:

* Save and Load entire game state
* Explosions in Chipmunk
* Creating a debug-layer
* Using impulses
* Retina Support

So what type of game should we do… perhaps one where we slingshot grenades at structures hoping to kill some kind of ninja animal inside? Sounds like a plan, so lets dive right in. This tutorial will use Cocos2d 0.99.5 and SpaceManager 0.0.6. I HIGHLY recommend you download the accompanying source code for this article so you can follow along; this will have everything you need and you can skip the setup steps. Source is found here:

Download the Source-Code: GrenadeGame.zip

Edit: Updated source location

Continue reading ‘A SpaceManager Game’

VertexHelper: A physics body editor

VertexHelper is a nifty little tool I (jfahrenkrug) have put together while developing a cocos2d iPhone app that used a lot of different sprites. All those sprites needed a counterpart for the physics engine, namely vertices. After defining the vertices of the 2nd sprite by hand, I knew that I’d go nuts if I had to define all 40 sprite vertices like that. So I wrote a tool: VertexHelper.

It lets you graphically define vertices of sprites for Box2D and Chipmunk bodies/shapes. You can find it on github or you can download a tarball of the source.

It is really easy to use VertexHelper:

  • First, you need an evenly spaced sprite sheet (every sprite in the image file has to be of the same size). For example, if your sprite sheet image is 250 x 120 pixels and every sprite is 50 x 60 pixels, then you’d have 10 sprites on your sheet (2 rows and 5 columns). Perfect.
  • Simply drag the sprite sheet image onto VertexHelper and enter the number of rows and columns. You’ll see a grid appear.
  • Now check the “Edit Mode” checkbox and click “around” each sprite to define it’s vertices. It’s that easy.
  • VertexHelper will generate the code for either Chipmunk or Box2D that you can simply cut and paste into your project.

A word of caution: You have to make sure not to define concave polygons, since both Chipmunk and Box2D don’t support them. VertexHelper won’t warn you if you do. Also, you have to make sure that you define your coordinates in the correct order: For Box2D, they have to be counter-clockwise and clockwise for Chipmunk.

But enough of the talking, this video gives you a much better impression of what VertexHelper does and how it works:

I hope it’s useful for you and please feel free to fork it on github and make it better for everyone!

For further updates, follow me on Twitter or keep an eye on my blog.




Social Widgets powered by AB-WebLog.com.