Example Code
Chipmunk2D Demo App: (C / Mac / Windows / Linux)
Check out the Demo application bundled with the standard Chipmunk2D distribution as well as the embedded examples in the documentation.
The Chipmunk2D showcase app takes full advantage of Chipmunk2D Pro to provide a high performance demo app on iOS while showing you how simple using it can be. The code is available from GitHub.
Cloud Bomber: (Objective-Chipmunk2D / Autogeometry / Cocos2D 2.1)
- Integrate Objective-Chipmunk2D with Cocos2D 2.1 using the new CCPhysicsSprite and CCPhysicsDebugNode classes.
- Implement deformable terrain using a ChipmunkBitmapSampler subclass that is backed by Cocos2D rendering. This is very easy for small terrain that changes rarely. Not as good for large terrain, or terrain that changes rapidly. (More demos to come to cover that).
- Render holes in a CCRenderTexture necessary to render the terrain.
Gemeralds Pinball: (Objective-Chipmunk2D / Autogeometry / Cocos2D 2.1 / CocosBuilder)
- Use CocosBuilder to create a level and then make Chipmunk2D collision geometry for it automatically at runtime.
- Integrate Objective-Chipmunk2D with Cocos2D 2.1 using the new CCPhysicsSprite and CCPhysicsDebugNode classes.
- Make a pinball game including how to make the physics for flippers and bumpers.
Space Patrol: (Objective-Chipmunk2D / Autogeometry / Cocos2D 2.1)
- Implement extremely large scale, and highly efficient deformable terrain. The terrain in this demo is initialized from a 12 KB png file and produces smoothly deformable terrain that is over 128,000 pixels wide on a retina scale display.
- Efficient terrain and parallax rendering in a single pass using pixel shaders.
- Efficient terrain geometry generation using a tile cache.
- Efficiently update the terrain detail texture using glTexSubImage2D().
- Set up car physics for a dune buggy including motor and braking controls.
- Manually sync sprites to a complicated articulated model for pixel perfect alignment.
Angry Chipmunks: (Objective-Chipmunk2D / Cocos2D 2.1)
- Create a GameObject class to help bind Cocos2D sprites and physics objects together and easily manange them.
- Use the integrated CCDebugNode and CCPhysicsSprite classes.
- Use the ChipmunkObject protocol to easily manage composite physics objects.
- Use collision handlers to recieve collision events from the physics system.
- Create breakable physics objects.
- Use layers to put physics objects inside of each other.
- Estimate the path of an object and where and when it will first collide with something.
Deformable Chipmunk2D: (Objective-Chipmunk2D / Autogeometry / Mac)
This project shows you a number of things that you can do with Chipmunk2D Pro's Autogeometry features without a lot of effort.
- Converting images into collision outlines for level terrain as well as creating convex hulls for sprites.
- Create infinite, procedural, deformable caves using a minimal amount of RAM.
- Fast, real-time, editable, deformable terrain using drawing contexts.
You can see these demonstrated
this YouTube screencast.
Jelly Chipmunk: (Objective-Chipmunk2D / Mac)
Simple example showing how to perform blob / jelly physics.
The blob can be grabbed with the mouse using Objective Chipmunk2D's ChipmunkMultiGrab class, or rolled using the arrow keys.
Very simple Cocos2D example showing how to do multi-touch physics using Objective-Chipmunk2D's ChipmunkMultiGrab class.
iPhoneSnap (Objective-Chipmunk2D / UIKit)
Simple physics based board game using Objective-Chipmunk2D and UIKit.
Shows how using Objective-Chipmunk2D / UIKit can be very effective and simple for games with low performance requirements.
Using UIKit for a game like this that stops animating between turns is also a terrific way to cut down on battery usage.
This example shows how to create a simple command line tool to export geometry for an image.
It uses ImageIO to load any sort of image that OS X knows how to load.
It can be easily integrated into your project as a build phase to automatically trace your images when running a build.