The Command line interface (CLI) is an incredibly powerful tool in your development arsenal and this first post in a series aims to get you up to speed while minimising the chance of serious damage. The terminal is your friend and your window onto the CLI, however it’s a friend that takes everything you say literally so be very careful what you ask it to do.

Opening a terminal

The easiest way to open a standard terminal is via spotlight. Command + Space will bring up spotlight then type Terminal

My personal preference is to use a free third party application called TotalTerminal which enables access to the terminal via a hot key combination (default CNTRL + ` ) and reveals it in a rather nifty slide and fade in effect. In spotlight Command + Space its accessible via TotalTerminal.

I’ve been looking forward to a Cocos2dx book ever since Cocos2dx branched from Cocos2d-iPhone and this book met my requirements perfectly.

It’s a beginners guide but some existing programming knowledge is assumed, if you’re familiar with Cocos2d-iPhone the book removes much of the pain in transitioning to Cocos2dx.

A quick read through the table of contents reveals a lot of content crammed into just over 200 pages but the structure is good and I found myself flying through the chapters.

Each Chapter clearly lays out at the beginning what you will learn. Careful thought has gone into the order that the content is introduced and from the off you’re building game mechanics rather than menu systems and splash screens, an approach that reminds me of Emanuele Feronato’s Blog.Continue Reading →

A work around to change the default URL icon when adding web links to the dock in OSX. From this;

To this;

We can’t change the icon on the link itself but we can add the link to a folder and change the folder icon. The first step is to create a folder somewhere and drag the links into it from your browser of choice.Continue Reading →

I’m working on a CCNode explanation that I hope will clear up a lot of the confusion that pops up in the forum on a regular basis. In the meantime the following comes directly from the CCNode.m file;

/** CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode.
The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu.
The main features of a CCNode are:
- They can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc)
- They can schedule periodic callback (schedule, unschedule, etc)
- They can execute actions (runAction, stopAction, etc)
Some CCNode nodes provide extra functionality for them or their children.
Subclassing a CCNode usually means (one/all) of:
- overriding init to initialize resources and schedule callbacks
- create callbacks to handle the advancement of time
- overriding draw to render the node
Features of CCNode:
- position
- scale (x, y)
- rotation (in degrees, clockwise)
- CCCamera (an interface to gluLookAt )
- CCGridBase (to do mesh transformations)
- anchor point
- size
- visible
- z-order
- openGL z position
Default values:
- rotation: 0
- position: (x=0,y=0)
- scale: (x=1,y=1)
- contentSize: (x=0,y=0)
- anchorPoint: (x=0,y=0)
Limitations:
- A CCNode is a "void" object. It doesn't have a texture
Order in transformations with grid disabled
-# The node will be translated (position)
-# The node will be rotated (rotation)
-# The node will be skewed (skewX, skewY)
-# The node will be scaled (scale, scaleX, scaleY)
-# The node will be moved according to the camera values (camera)
Order in transformations with grid enabled
-# The node will be translated (position)
-# The node will be rotated (rotation)
-# The node will be skewed (skewX, skewY)
-# The node will be scaled (scale, scaleX, scaleY)
-# The grid will capture the screen
-# The node will be moved according to the camera values (camera)
-# The grid will render the captured screen
Camera:
- Each node has a camera. By default it points to the center of the CCNode.
*/

Some points to note;

* they can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc)
* A CCNode is a “void” object. It doesn’t have a texture and so…
* has a default contentSize: (x=0,y=0) (CCSprites set their initial contentSize from the size of the supplied texture)
* has a default anchorPoint: (x=0,y=0) (0.5f,0.5f makes no sense when the node has no size)
* Each node has a camera. By default it points to the center of the CCNode.

Apple has finally approved my #1GAM entry for January, it was initially rejected for a metadata issue and some confusion as to what the app actually was.

It’s pretty simple and isn’t written in cocos2d this time but I did get it submitted to the app store within the onegameamonth.com January deadline. I’d initially resigned myself on the 31st January to missing the submission and getting a late one in but a quick change of heart (and project idea) and I was off. The game is an audio version of Simon Says and was designed to minimise the need to look at the screen. This enabled a quicker development time as I didn’t need visual assets or screen transitions and meant that with headphones on, the game could be played while in your pocket.

If you’ve not signed up for #1GAM it’s not too late, head over to http://onegameamonth.com and jump in, it’s a great way to break out of a rut and get those project ideas that don’t seem to fit in anywhere out into the world.

I’d hoped to get this up before Christmas but along with the rest of the UK I spent a large portion of the festive holidays feeling a tad under the weather. There’s been a link to the preview copy of this book in my Cocos2D Getting started post for a while and even in its sample form it was a great resource for someone looking to get started with writing games for iDevices.Continue Reading →

If you get a permissions issue when installing you may need to use sudo

>sudo python setup.py install

pdfMiner also comes with a couple of additional tools and some sample content so you can get started straight away

>pdf2txt.py samples/simple1.pdf

It does a reasonable job of delivering text in the correct order, but your mileage will vary depending on what you used to create the PDF and its complexity. Titles sat amongst multiple columns for example can cause some issues.

Three years ago there was a dearth of tools for cocos2d development. It’s a lot better now. This is not a comprehensive list of all the tools out there but covers the ones I’ve tried and found useful. If you’re looking for something and it’s not in the list try the Cocos2d forum, there’s a sub forum specifically for editors/tools.

Some of the tools are free, others have trial versions so you can try them out before purchasing, those that are not free I have paid for personally. A few of the tools started out with less features and early adopters were rewarded with a lower price, as the tools have had features added the price has increased to reflect this. Getting in on an app early helps support the developer in the early stages while often saving you money over time.

The sample code alongside some of the apps below is not meant to serve as best practice, they’re small code snippets that will hopefully help find the answers you’re looking for in google/cocos2d forums. A search for CCLabelBMFont should bring up far better cocos2d specific label answers than typing in ‘label‘. This article follows on from the Cocos2d – Getting started post.

Graphics tools

Particle Designer

Paid app available from the Particle designer site. Before particle designer, trying to get a particular look for a particle system in cocos2d was a long winded process of trial and error, change some values in the code, build, run, change, build, run etc. Particle designer is a Mac app that gives you a dashboard of sliders and a preview so you can modify your particle system on the fly. When you’ve finished you simply select the embedded texture option, save out as a cocos2d plist and add it to your project.

For a plist saved out as myParticleSystem.plist get your particle effect to appear in your project using the following code;

// 1. Create a particle emitter using the setting in the plist file. ARCH_OPTIMAL_PARTICLE_SYSTEM// is a macro that picks the optimal particle system for the device you're running on.
CCParticleSystem *emitter =[ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"myParticleSystem.plist"];
// 2. Add the particle system[self addChild:emitter];

Particle designer has a random mode and also contains a library of shared emitters submitted by other users.Continue Reading →

The result

The approach uses a greyscale image saved out in raw format to provide us with height information based on pixel position. In the example project (download link at bottom of page) I use this to affect the scale of a sprite, this can be seen in the video. Each pixel has 256 possible values, I’ve used 0 to represent the highest points and 255 the lowest.Continue Reading →