Physics can be a great way to enhance your game.
The problem is that implementing physics in your game can be extremely challenging, but I found a couple of great examples showing how to enhance an iPhone or iPad game using radial gravity with Box2D.
The examples are from Nick Vellios, and as you can see in the example above they show how to implement radial gravity on an object so that other objects are drawn towards it (much like how planets are drawn to the sun).
The examples include:
And a third example on inverse radial gravity (think of objects exploding in all directions)
Bombs With Box 2D and Cocos2D
Cocos2D is used as the rendering engine in the examples.
By the way, can anyone remember the name of the nifty puzzle game that used radial gravity and won numerous indie gaming awards about 12 years ago? (yeah i’m stretching)
Thanks for reading, if you like this please share it!
Box2D is a full-featured open source physics engine that has been used in many iPhone and iPad games. It is often used with the excellent Cocos2D graphics engine.
Oliver Drobnik has created an excellent example of using Box2D with the UIKit. This is a great example for those who are not familiar with, or don’t have any interest in using Cocos 2D.
[Source: Dr. Touch]
If you’ve done any 2D action game programming you may have had to go through the tedious process of going through a collection of 2D sprites and finding and recording vertex coordinates around the game objects.
It’s a major hassle to do this by hand, and for me personally it’s things like this that hold me back from doing things, or sometimes taking an easier way out (like using box collisions or spherical collisions just so I don’t have to do this), but it’s a fairly quick process selecting things graphically with this program
Fortunately Johannes Fahrenkrug has created a very nice time saving tool for getting these vertex locations, see this video of it in action:
As you can see it can even print out formats specifically for Box2D and Chipmunk which is great for Cocos2D fans.
You can download the source here on git: VertexHelper with a full Xcode project for easy compilation on your Mac (sorry windows users).
[Source: Springenwerk Blog by Johannes Fahrenkrug]