Posts

Showing posts from July, 2010

cocos2d as an Application Framework - Part 4

Image
[Concrete/Interesting] So far I think the experiment to use cocos2d as an application framework has been successful. With little effort we have a very nice look and feel, excellent menu behaviour on an iPhone and a charming looking popup dialog. Better than that, it seems relatively easy to mix UI framework into cocos2d – UI Views for example seem to behave well when added as nodes to a scene. In this last part, I’m going to try something a little more challenging. What I want to build is a sexy About box. I ;want to mix animation, a scrolling text view and a background camera view using UIImagePickerController. Containing cocos2d in a UIViewTo show a camera surface as the background of our cocos2d scene, we are going to have to place the cocos2d as a subview of our window’s main view. We also need to make the cocos2d scene transparent. This is a little tricky but here’s how.Look again at the selector applicationDidFinishLaunching: in the application delegate. The delegate manages th…

cocos2d as an Application Framework – Part 3

Image
[Concrete/Interesting] It’s all starting to come together. We have a application and a very interesting look and feel for the menu.Now I want to really mix it up. I want to display something similar to that provided by UIAlertView, but the one from Apple just doesn’t fit the look and feel of the application under the cocos2d framework. Custom Alert in UI KitImplementing a modal alert is relatively simple, I need create a XIB file with a single UIView:My alert view has a title, message body and two buttons, all in a nice warm look and feel:These tie back to the class definition as show in the code below:#import <UIKit/UIKit.h> #import "ColourfulButton.h" @interface ModalAlert : UIViewController { IBOutlet UILabel *alertTitle; IBOutlet UILabel *alertMessage; IBOutlet ColourfulButton *alertCancel; IBOutlet ColourfulButton *alertOk; int nResult; } @property (nonatomic, retain) UILabel *alertTitle; @property (nonatomic, retain) UILabel *alertMessage; @property (non…

cocos2d as an Application Framework – Part 2

Image
[Concrete/Interesting] In the previous blog I looked at cocos2d and showed how a simple menu could be created with very little effort.The menu is quite funky but not that exciting. cocos2d supports Sprites, so let’s build a menu with animated sprites, something like the Cover Flow you find in iTunes.Cover Flow MenuFor a more exciting look and feel for the menu, I’m going to do a couple of things. First, I’m going to change the visual behaviour of the menu items – give them a sprite as well as text. Second, I’m going to modify the visual and input behaviour of the menu (the container for the menu items) to animate the menu items.For the menu items, I have to first create a class that inherits from CCMenuItem:#import <foundation/foundation.h> #import "cocos2d.h" @interface MenuItemComplete : CCMenuItem <CCRGBAProtocol> { CCLabel *title; CCNode<CCRGBAProtocol> *sprite; CCNode<CCRGBAProtocol> *spriteDisabled; float originalScale_; } @property (nona…

cocos2d as an Application Framework – Part 1

Image
[Concrete/Interesting] cocos2d is a multi-platform games engine written in C/C++. It has been ported to a number of environments including the iPhone under Objective-C. Like all developers, I dream of creating the most popular game ever. I’m probably a little too late because Pac Man day’s have come and gone. However, I believe the foundation of a games engine has application outside of the realm of games.In this first part I will be discussing the use of the cocos2d games engine as an application framework. In later articles I will expand on this to show how we can mix elements of cocos2d and the iPhone UI Framework.Basic Elements of a Games EngineTake a look at Adobe Air and even Microsoft Silverlight. Under these frameworks applications are better thought of as scenes, with layers and objects (nodes on the scene). These objects may be animation or sprites (for instance a ‘Busy’ animation) or they may be user interface elements like labels, button or menus. Layers are groups of nod…

Space and Time

Image
[Abstract/ Sharing]  Here is a short poem about Space and Time. Someone said the present is brief and precious and we can never get back moment that are lost. I disagreeThis poem offers an alternative view, talking about events in space/time with the present flowing through this landscape. I also make reference to the c-boundary confining all space and time. Hope you enjoy:
Events frozen into the fabric of Space and Time,
The Present rushing past at the Speed of Light.

The Past and Future everywhere, less the edge of the Universe
Where possibility and history remains void.