<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>abitofcode</title>
	
	<link>http://abitofcode.com</link>
	<description />
	<lastBuildDate>Fri, 24 May 2013 09:52:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/abitofcode/JoZG" /><feedburner:info uri="abitofcode/jozg" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>COCOS2d-X by Example Beginner’s Guide by Roger Engelbert (Packt Publishing)</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/M0IN3WEtFuA/</link>
		<comments>http://abitofcode.com/2013/05/cocos2d-x-by-example-beginners-guide-by-roger-engelbert-packt-publishing/#comments</comments>
		<pubDate>Sun, 12 May 2013 18:54:06 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=1419</guid>
		<description><![CDATA[I&#8217;ve been looking forward to a Cocos2dx book ever since Cocos2dx branched from Cocos2d-iPhone and this book met my requirements perfectly. It&#8217;s a beginners guide but some existing programming knowledge is assumed, if you&#8217;re familiar with Cocos2d-iPhone the book removes &#8230; <a href="http://abitofcode.com/2013/05/cocos2d-x-by-example-beginners-guide-by-roger-engelbert-packt-publishing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/cocos2d-x-by-example/book"><img src="http://abitofcode.com/wp-content/uploads/2013/05/Cocos2dXCover-244x300.jpg" alt="Cocos2d-X by Example Beginner&#039;s Guide" width="244" height="300" class="alignleft size-medium wp-image-1431" /></a><br />
I&#8217;ve been looking forward to a Cocos2dx book ever since <a href="http://www.cocos2d-x.org/">Cocos2dx</a> branched from <a href="http://www.cocos2d-iphone.org/">Cocos2d-iPhone</a> and this book met my requirements perfectly.</p>
<p>It&#8217;s a beginners guide but some existing programming knowledge is assumed, if you&#8217;re familiar with Cocos2d-iPhone the book removes much of the pain in transitioning to Cocos2dx. </p>
<p>A quick read through the <a href="http://www.packtpub.com/cocos2d-x-by-example/book#support">table of contents</a> reveals a lot of content crammed into just over 200 pages but the structure is good and I found myself flying through the chapters. </p>
<p>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&#8217;re building game mechanics rather than menu systems and splash screens, an approach that reminds me of <a href="http://www.emanueleferonato.com/">Emanuele Feronato&#8217;s Blog</a>.<br />
<span id="more-1419"></span><br />
Techniques are introduced once and repetition is avoided allowing more material to be covered in fewer pages, the code for all the example projects is available for download and commented. </p>
<p>It&#8217;s written in a friendly style and much like the StanfordU iOS lectures cuts through waffle;</p>
<blockquote><p>So what is a 2D framework? If I had to define it in as few words as possible, I&#8217;d say: rectangles in a loop.
</p></blockquote>
<p>Having avoided C++ for as long as possible I was a little dubious as to how the book would cover it. Enough help is given in the early chapters to get on with using the framework and this was all that was needed to get stuck in. Familiarity with C++ will grow as you use it and with Cocos2dx being open source you can pick up techniques looking through the source code.</p>
<p>The book aims to develop your Cocos2dx skills by following through the development of 6 games. As well as basing each game around a different game mechanic the author also throws in some practical game development techniques along the way. Rapid prototyping introduced in chapter 4 helps to keep the reader focussed on building something playable rather than getting bogged down too early with the detail.</p>
<h3>The games</h3>
<ol>
<li>Air Hockey</li>
<li>Sky defense</li>
<li>Rocket through</li>
<li>Victorian Rush hour</li>
<li>Pool</li>
<li>Eskimo</li>
</ol>
<p><a href="http://rengelbert.com/blog/cocos2d-x-the-book/">Screenshots</a> of the games are available over at <a href="http://rengelbert.com/blog">Roger Engelberts blog</a></p>
<p>Amongst the techniques discussed;</p>
<p>Multi touch, supporting multiple resolutions, roll your own collision detection, Sprite sheets, bitmap fonts, actions, animation, Particle systems, Drawing primitives, vector maths, rapid prototyping, placeholder sprites, platform game collision code, side scroller terrain generation, Box2d, cross platform development &#8230;</p>
<p>The final chapter &#8216;Code once. Retire&#8217;, covers setting up a hybrid iOS/Android project. It&#8217;s this type of chapter that usually goes out of date before the book hits the shelves however the chapter does attempt an explanation of the process rather than a list of actions to blindly follow.</p>
<p>The Appendix &#8216;Vector Calculations with Cocos2d-x&#8217; is a great resource for anyone struggling with subjects like dot products and angular based speed.</p>
<p>I really enjoyed this book, Roger has done a great job at making the subject both friendly and approachable and the example games cover a wide range of techniques. If you&#8217;re currently turning work away because you don&#8217;t support Android development this is a great place to start.</p>
<p><strong>edit:</strong> There are a few deprecations in the latest release of Cocos2d-x that are not reflected in the book or errata, if you&#8217;re having any problems the following link may help;</p>
<p><a href="http://www.cocos2d-x.org/reference/native-cpp/da/d58/deprecated.html">Deprecations since the book release</a></p>
<h3>Overview:</h3>
<ul>
<li>Learn to build multi-device games in simple, easy steps, letting the framework do all the heavy lifting</li>
<li>Spice things up in your games with easy to apply animations, particle effects, and physics simulation</li>
<li>Quickly implement and test your own gameplay ideas, with an eye for optimization and portability</li>
<li>Enjoy building the games as much as you will enjoy playing them</li>
</ul>
<hr id="comp" />
<h2>Win Free e-copies of Cocos2d-X by Example Beginner&#8217;s Guide</h2>
<p>You&#8217;ll be pleased to know that I have teamed up with the nice people at Packt Publishing to organize a Giveaway of Cocos2d-X by Example Beginner&#8217;s Guide</p>
<p><strong>3 lucky winners</strong> stand a chance to win e-copies of their new book. </p>
<h3>How to Enter?</h3>
<p>All you need to do for a chance to win is head on over to the <a href="http://www.packtpub.com/cocos2d-x-by-example/book">book page</a> and look through the product description of the book and drop a line via the comments below this post to let us know what interests you the most about this book. It’s that simple.</p>
<h3>Deadline</h3>
<p>The contest will close on May 30, 2013. Winners will be contacted by email, so be sure to use your real email address when you comment!</p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/M0IN3WEtFuA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2013/05/cocos2d-x-by-example-beginners-guide-by-roger-engelbert-packt-publishing/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2013/05/cocos2d-x-by-example-beginners-guide-by-roger-engelbert-packt-publishing/</feedburner:origLink></item>
		<item>
		<title>Creating a custom URL icon in the dock</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/yrBetl0cAmw/</link>
		<comments>http://abitofcode.com/2013/04/creating-a-custom-url-icon-in-the-dock/#comments</comments>
		<pubDate>Thu, 11 Apr 2013 15:39:43 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[dock]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=1360</guid>
		<description><![CDATA[A work around to change the default URL icon when adding web links to the dock in OSX. We can&#8217;t change the icon on the link itself but we can add the link to a folder and change the folder &#8230; <a href="http://abitofcode.com/2013/04/creating-a-custom-url-icon-in-the-dock/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A work around to change the default URL icon when adding web links to the dock in OSX.<br />
<a href="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_a.png"><img src="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_a.png" alt="2013_04_11_a" width="485" height="101" class="aligncenter size-full wp-image-1362" /></a></p>
<p>We can&#8217;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.<br />
<span id="more-1360"></span></p>
<h3>Changing the folder icon</h3>
<p>Find the image you want to use as the new icon and grab a squareish section of it using preview. We need to grab this into the clipboard using Copy (&#8984; + c). Alternatively you can screen capture it directly using &#8679; + &#8984; + 4 to bring up a selection crosshairs and then before making the selection holding down the Control key to copy directly into the clipboard rather than depositing the selection as a file on the Desktop.</p>
<p><a href="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_g.png"><img src="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_g.png" alt="2013_04_11_g" width="609" height="463" class="aligncenter size-full wp-image-1382" /></a></p>
<p>Select the folder to have it&#8217;s icon changed and open the Info panel (&#8984; + i)<br />
<a href="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_f.png"><img src="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_f.png" alt="2013_04_11_f" width="439" height="706" class="aligncenter size-full wp-image-1378" /></a></p>
<p>Select the small Icon towards the top of the Info panel and Paste the contents of the clipboard (&#8984; + v). The folder icon should now be your selected image.</p>
<p><a href="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_h.png"><img src="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_h.png" alt="2013_04_11_h" width="444" height="707" class="aligncenter size-full wp-image-1387" /></a></p>
<h3>Adding the link to the Dock</h3>
<p>Drag the updated folder onto the right hand side of the Dock (anywhere after the dividing line). If it doesn&#8217;t show the new icon make sure you have it selected to <strong>display as Folder and not Stack</strong> (right click on the folder to find this setting).</p>
<p><a href="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_c.png"><img src="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_c.png" alt="2013_04_11_c" width="283" height="98" class="aligncenter size-full wp-image-1370" /></a></p>
<p>When the folder is selected the links inside will be displayed.</p>
<p><a href="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_d.png"><img src="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_d.png" alt="2013_04_11_d" width="452" height="244" class="aligncenter size-full wp-image-1371" /></a></p>
<p>I have a folder set up within Applications to group all the cocos2d tools I use regularly and have used the same approach to make the folder a little more recognisable.</p>
<p><a href="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_e.png"><img src="http://abitofcode.com/wp-content/uploads/2013/04/2013_04_11_e.png" alt="2013_04_11_e" width="318" height="89" class="aligncenter size-full wp-image-1375" /></a></p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/yrBetl0cAmw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2013/04/creating-a-custom-url-icon-in-the-dock/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2013/04/creating-a-custom-url-icon-in-the-dock/</feedburner:origLink></item>
		<item>
		<title>Demystifying CCNode</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/LVy9-yhqIh8/</link>
		<comments>http://abitofcode.com/2013/02/demystifying-ccnode/#comments</comments>
		<pubDate>Fri, 15 Feb 2013 15:07:19 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Cocos2d]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=1337</guid>
		<description><![CDATA[I&#8217;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 &#8230; <a href="http://abitofcode.com/2013/02/demystifying-ccnode/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;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;</p>

<div class="wp_codebox"><table><tr id="p13372"><td class="code" id="p1337code2"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">/** 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.
&nbsp;
 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)
&nbsp;
 Some CCNode nodes provide extra functionality for them or their children.
&nbsp;
 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
&nbsp;
 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
&nbsp;
 Default values:
  - rotation: 0
  - position: (x=0,y=0)
  - scale: (x=1,y=1)
  - contentSize: (x=0,y=0)
  - anchorPoint: (x=0,y=0)
&nbsp;
 Limitations:
 - A CCNode is a &quot;void&quot; object. It doesn't have a texture
&nbsp;
 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)
&nbsp;
 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
&nbsp;
 Camera:
 - Each node has a camera. By default it points to the center of the CCNode.
 */</span></pre></td></tr></table></div>

<p>Some points to note;</p>
<p>* they can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc)<br />
* A CCNode is a &#8220;void&#8221; object. It doesn&#8217;t have a texture and so&#8230;<br />
* has a default contentSize: (x=0,y=0) (CCSprites set their initial contentSize from the size of the supplied texture)<br />
* has a default anchorPoint: (x=0,y=0) (0.5f,0.5f makes no sense when the node has no size)<br />
* Each node has a camera. By default it points to the center of the CCNode.</p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/LVy9-yhqIh8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2013/02/demystifying-ccnode/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2013/02/demystifying-ccnode/</feedburner:origLink></item>
		<item>
		<title>#1GAM January entry – Repetitive (free)</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/rn5OzZ_-NNs/</link>
		<comments>http://abitofcode.com/2013/02/1gam-january-entry-repetitive/#comments</comments>
		<pubDate>Mon, 11 Feb 2013 15:33:32 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[#1GAM]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=1290</guid>
		<description><![CDATA[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&#8217;s pretty simple and isn&#8217;t written in cocos2d this time but I did &#8230; <a href="http://abitofcode.com/2013/02/1gam-january-entry-repetitive/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="https://itunes.apple.com/gb/app/repetitive/id598795971?mt=8"><img src="http://abitofcode.com/wp-content/uploads/2013/02/Screen-Shot-2013-02-11-at-14.29.48.png" alt="Repetitive" width="189" height="188" class="alignleft size-full wp-image-1298" /></a></p>
<p>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.</p>
<p>It&#8217;s pretty simple and isn&#8217;t written in cocos2d this time but I did get it submitted to the app store within the <a href="http://onegameamonth.com">onegameamonth.com</a> January deadline. I&#8217;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&#8217;t need visual assets or screen transitions and meant that with headphones on, the game could be played while in your pocket.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/7C6A0JYxdoU?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p><a href="http://onegameamonth.com"><img src="http://abitofcode.com/wp-content/uploads/2013/02/logo.png" alt="OneGameAMonth" width="768" height="80" class="alignleft size-full wp-image-1318" /></a><br />
<br />
If you&#8217;ve not signed up for #1GAM it&#8217;s not too late, head over to <a href="http://onegameamonth.com">http://onegameamonth.com</a> and jump in, it&#8217;s a great way to break out of a rut and get those project ideas that don&#8217;t seem to fit in anywhere out into the world.</p>
<p>In all the game plus submission took around 3.5 hours to write.</p>
<h3>Development notes</h3>
<p>The audio assets were created using the terminal command &#8216;say&#8217;</p>
<div class="terminal">
say -vTrinoids Left, Right, Up, Down, Tap
</div>
<p><span id="more-1290"></span><br />
During development I threw together a quick script so I could try out different voices, this created a caf file named after the spoken work within it.</p>

<div class="wp_codebox"><table><tr id="p12907"><td class="code" id="p1290code7"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> audio2
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> lines.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line
<span style="color: #000000; font-weight: bold;">do</span>
   <span style="color: #666666; font-style: italic;"># do something with $line here</span>
   say <span style="color: #660033;">-vTrinoids</span> <span style="color: #007800;">$line</span> <span style="color: #660033;">-o</span> audio2<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$line</span>.aiff
   afconvert <span style="color: #660033;">-d</span> LEI16 <span style="color: #660033;">-f</span> <span style="color: #ff0000;">'caff'</span> audio2<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$line</span>.aiff audio2<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$line</span>.caf   
   <span style="color: #c20cb9; font-weight: bold;">rm</span> audio2<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$line</span>.aiff
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>Where lines.txt is a simple text file containing the words I needed, not so good with multiple words on a line :S</p>

<div class="wp_codebox"><table><tr id="p12908"><td class="code" id="p1290code8"><pre class="text" style="font-family:monospace;">up,
down,
left,
right, 
tap,
play,</pre></td></tr></table></div>

<p>Grabbing the gestures was simple using apples gesture recognisers;</p>

<div class="wp_codebox"><table><tr id="p12909"><td class="code" id="p1290code9"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> addGestures
<span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// Single Tap</span>
    UITapGestureRecognizer <span style="color: #002200;">*</span>tapRecognizer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITapGestureRecognizer alloc<span style="color: #002200;">&#93;</span> initWithTarget<span style="color: #002200;">:</span>&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;&lt;span class<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;hiddenGrammarError&quot;</span> pre<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;&quot;</span>&gt;self
                                                                                    action&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;&lt;<span style="color: #002200;">/</span>span&gt;<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>onViewSingleTap<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
    tapRecognizer.numberOfTapsRequired <span style="color: #002200;">=</span> <span style="color: #2400d9;">1</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Swipe up</span>
    UISwipeGestureRecognizer<span style="color: #002200;">*</span> swipeUpGestureRecognizer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UISwipeGestureRecognizer alloc<span style="color: #002200;">&#93;</span> initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>handleSwipe<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
    swipeUpGestureRecognizer.direction <span style="color: #002200;">=</span> UISwipeGestureRecognizerDirectionUp;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Swipe left</span>
    UISwipeGestureRecognizer<span style="color: #002200;">*</span> swipeLeftGestureRecognizer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UISwipeGestureRecognizer alloc<span style="color: #002200;">&#93;</span> initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>handleSwipe<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
    swipeLeftGestureRecognizer.direction <span style="color: #002200;">=</span> UISwipeGestureRecognizerDirectionLeft;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Swipe right</span>
    UISwipeGestureRecognizer<span style="color: #002200;">*</span> swipeRightGestureRecognizer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UISwipeGestureRecognizer alloc<span style="color: #002200;">&#93;</span> initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>handleSwipe<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
    swipeRightGestureRecognizer.direction <span style="color: #002200;">=</span> UISwipeGestureRecognizerDirectionRight;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Swipe down</span>
    UISwipeGestureRecognizer<span style="color: #002200;">*</span> swipeDownGestureRecognizer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UISwipeGestureRecognizer alloc<span style="color: #002200;">&#93;</span> initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>handleSwipe<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
    swipeDownGestureRecognizer.direction <span style="color: #002200;">=</span> UISwipeGestureRecognizerDirectionDown;
&nbsp;
&nbsp;
    <span style="color: #002200;">&#91;</span>self.view addGestureRecognizer<span style="color: #002200;">:</span>tapRecognizer<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>self.view addGestureRecognizer<span style="color: #002200;">:</span>swipeUpGestureRecognizer<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>self.view addGestureRecognizer<span style="color: #002200;">:</span>swipeLeftGestureRecognizer<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>self.view addGestureRecognizer<span style="color: #002200;">:</span>swipeRightGestureRecognizer<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>self.view addGestureRecognizer<span style="color: #002200;">:</span>swipeDownGestureRecognizer<span style="color: #002200;">&#93;</span>;    
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>While handling the audio was made a lot easier using <a href="http://kstenerud.github.com/ObjectAL-for-iPhone/">ObjectAL for iPhone</a> by Karl Stenerud. The only issue I had with the audio was needing to know when one sound had finished so I could start the next, I opted in the end to schedule an NSTimer to play them one by one after a delay that gave enough time for the previous time to finish.</p>

<div class="wp_codebox"><table><tr id="p129010"><td class="code" id="p1290code10"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;ObjectAL.h&quot;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// create NSArray of actions</span>
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, strong<span style="color: #002200;">&#41;</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a>    <span style="color: #002200;">*</span>actions;
self.actions <span style="color: #002200;">=</span> @<span style="color: #002200;">&#91;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;up&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;down&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;left&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;right&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;tap&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// This loads the sound effects into memory so that</span>
<span style="color: #11740a; font-style: italic;">// there's no delay when we tell it to play them.</span>
<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>action <span style="color: #a61390;">in</span> _actions<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
  <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>filename <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>action stringByAppendingPathExtension<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;caf&quot;</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>OALSimpleAudio sharedInstance<span style="color: #002200;">&#93;</span> preloadEffect<span style="color: #002200;">:</span>filename<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Grab a random action from the actions array</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>randomAction
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>_actions objectAtIndex<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>arc4random<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">%</span> _actions.count<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Here we play 'play.caf' but we could be playing a sound returned by the</span>
<span style="color: #11740a; font-style: italic;">// randomAction method (remember to add .caf onto the end first)</span>
<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>OALSimpleAudio sharedInstance<span style="color: #002200;">&#93;</span> playEffect<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;play.caf&quot;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Then it just needed a simple state machine to get the gestures and audio playback/capture happening in the right order.</p>
<p>The scoring display was added later initially as a way for me to test it was working.</p>
<p>There&#8217;ll shortly be an update to address a couple of issues including a minor audio bug (and the mis-alignment of the headphones in the icon which is annoying <a href="http://www.twitter.com/creativewax">@creativewax</a>)</p>
<p><a href="https://itunes.apple.com/gb/app/repetitive/id598795971?mt=8"><img src="http://abitofcode.com/wp-content/uploads/2013/02/Repetitive.jpg" alt="Repetitive" width="450" height="707" class="aligncenter size-full wp-image-1308" /></a></p>
<p><a href="https://itunes.apple.com/gb/app/repetitive/id598795971?mt=8"><img src="http://abitofcode.com/wp-content/uploads/2013/02/Download_on_the_App_Store_Badge_US-UK_135x40.png" alt="Download_on_the_App_Store_Badge_US-UK_135x40" width="135" height="40" class="alignleft size-full wp-image-1292" /></a></p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/rn5OzZ_-NNs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2013/02/1gam-january-entry-repetitive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2013/02/1gam-january-entry-repetitive/</feedburner:origLink></item>
		<item>
		<title>iOS Game Programming with Xcode and Cocos2d review</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/ZweZhWPWrZ8/</link>
		<comments>http://abitofcode.com/2013/01/ios-game-programming-with-xcode-and-cocos2d-review/#comments</comments>
		<pubDate>Tue, 15 Jan 2013 20:56:33 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=1261</guid>
		<description><![CDATA[I&#8217;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&#8217;s been a link to the preview copy of &#8230; <a href="http://abitofcode.com/2013/01/ios-game-programming-with-xcode-and-cocos2d-review/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.cartoonsmart.com/ibook.php5"><img src="http://abitofcode.com/wp-content/uploads/2013/01/id575333541.jpeg" alt="id575333541" width="171" height="225" class="alignleft size-full wp-image-1283" /></a>I&#8217;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&#8217;s been a link to the preview copy of this book in my <a href="http://abitofcode.com/2012/05/cocos2d-getting-started/">Cocos2D Getting started</a> 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.<br />
<span id="more-1261"></span><br />
So why give it a separate shout out? I have to be honest, I was given a review copy of the full book but I&#8217;d decided after reading the sample chapters that this was on my to buy list when available. The main reason for the plug is it&#8217;s very similar to an approach I&#8217;d had planned but just done so much better. </p>
<p>To borrow from the iTunes description text;</p>
<p><em>&#8220;Justin Dike teaches iOS game programming with Xcode and Cocos2d v2. Learn with HD images, interactive galleries, video examples, and color coded examples. Anyone learning Cocos2d or Xcode, beginner or otherwise, will benefit from this comprehensive book.</p>
<p>Topics specific to game programming include: collision detection, platform  collisions, virtual joysticks, accelerometer, 3D effects, animation,  particles, menus, sound FX, singleton classes, game engines, points, health meters, levelling up, and much more!&#8221;</em></p>
<p>A lot of work has gone into this, the structure is good and it&#8217;s an interesting read with videos that work with the content rather than being shoe horned in afterwards. </p>
<p><img src="http://abitofcode.com/wp-content/uploads/2013/01/2013_jan_ios1.jpg" alt="2013_jan_ios1" width="480" height="360" class="aligncenter size-large wp-image-1264" /></p>
<p><img src="http://abitofcode.com/wp-content/uploads/2013/01/2013_jan_ios2.jpg" alt="2013_jan_ios2" width="480" height="360" class="aligncenter size-large wp-image-1263" /></p>
<p><img src="http://abitofcode.com/wp-content/uploads/2013/01/2013_jan_ios3.jpg" alt="2013_jan_ios3" width="480" height="360" class="aligncenter size-full wp-image-1262" /></p>
<p>Don&#8217;t take my word for it, the first 4 chapters can be sampled for free.</p>
<p>For further information, a chapter by chapter breakdown and Cocos2d v2.1 ready code samples check out the following link.</p>
<p><a href="http://www.cartoonsmart.com/ibook.php5"><img src="http://abitofcode.com/wp-content/uploads/2013/01/logo_ios_game_book.png" alt="logo_ios_game_book" width="450" height="200" class="alignleft size-full wp-image-1273" /></a></p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/ZweZhWPWrZ8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2013/01/ios-game-programming-with-xcode-and-cocos2d-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2013/01/ios-game-programming-with-xcode-and-cocos2d-review/</feedburner:origLink></item>
		<item>
		<title>Quick text grab from Pdf</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/Y45EAg34yQU/</link>
		<comments>http://abitofcode.com/2012/10/quick-text-grab-from-pdf/#comments</comments>
		<pubDate>Mon, 01 Oct 2012 13:40:59 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[extract]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[scrape]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=1249</guid>
		<description><![CDATA[I needed to grab some text from a PDF for further processing and preferring CLI to GUI I thought I&#8217;d look for something that would work with my favourite tool of choice Python. Tried the following first; pyPDF &#8211; Output &#8230; <a href="http://abitofcode.com/2012/10/quick-text-grab-from-pdf/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I needed to grab some text from a PDF for further processing and preferring CLI to GUI I thought I&#8217;d look for something that would work with my favourite tool of choice Python.</p>
<p>Tried the following first;</p>
<p><a href="http://pybrary.net/pyPdf/">pyPDF</a> &#8211; Output a lot of junk, maybe a Unicode issue?<br />
<a href="http://www.swftools.org/">swfTools</a> &#8211; Required a bunch of libraries installing and seemed to be overkill for just grabbing a bit of text.</p>
<p>Then came across <a href="http://www.unixuser.org/~euske/python/pdfminer/index.html">pdfMiner</a> a PDF parser and analyzer written entirely in Python.  </p>
<p>Installation is simple, <a href="http://pypi.python.org/pypi/pdfminer/">download</a>, unpack and run setup.py;</p>
<div class="terminal">
>tar -xzvf pdfminer-20110515.tar.gz<br />
>cd pdfminer-20110515<br />
>python setup.py install
</div>
<p>If you get a permissions issue when installing you may need to use sudo</p>
<div class="terminal">
>sudo python setup.py install
</div>
<p>pdfMiner also comes with a couple of additional tools and some sample content so you can get started straight away <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<div class="terminal">
>pdf2txt.py samples/simple1.pdf
</div>
<p>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.</p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/Y45EAg34yQU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2012/10/quick-text-grab-from-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2012/10/quick-text-grab-from-pdf/</feedburner:origLink></item>
		<item>
		<title>Cocos2d – useful tools</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/GCSGOpECirw/</link>
		<comments>http://abitofcode.com/2012/07/cocos2d-useful-tools/#comments</comments>
		<pubDate>Thu, 05 Jul 2012 10:50:24 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[audacity]]></category>
		<category><![CDATA[cfxr]]></category>
		<category><![CDATA[cocos2d]]></category>
		<category><![CDATA[cocos2dx]]></category>
		<category><![CDATA[cocosbuilder]]></category>
		<category><![CDATA[dash]]></category>
		<category><![CDATA[designer]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[gimp]]></category>
		<category><![CDATA[glyph]]></category>
		<category><![CDATA[hue go]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[inkscape]]></category>
		<category><![CDATA[levelhelper]]></category>
		<category><![CDATA[particle desigenr]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[shipit]]></category>
		<category><![CDATA[spritehelper]]></category>
		<category><![CDATA[spriter]]></category>
		<category><![CDATA[texturepacker]]></category>
		<category><![CDATA[tiled]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[totalterminal]]></category>
		<category><![CDATA[xcode]]></category>
		<category><![CDATA[zwoptex]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=948</guid>
		<description><![CDATA[Three years ago there was a dearth of tools for cocos2d development. It&#8217;s a lot better now. This is not a comprehensive list of all the tools out there but covers the ones I&#8217;ve tried and found useful. If you&#8217;re &#8230; <a href="http://abitofcode.com/2012/07/cocos2d-useful-tools/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Three years ago there was a dearth of tools for cocos2d development. It&#8217;s a lot better now. This is not a comprehensive list of all the tools out there but covers the ones I&#8217;ve tried and found useful. If you&#8217;re looking for something and it&#8217;s not in the list try the Cocos2d forum, there&#8217;s a <a href="http://www.cocos2d-iphone.org/forum/forum/16">sub forum</a> specifically for editors/tools.</p>
<p>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.</p>
<p>The sample code alongside some of the apps below is not meant to serve as best practice, they&#8217;re small code snippets that will hopefully help find the answers you&#8217;re looking for in google/cocos2d forums. A search for <em>CCLabelBMFont</em> should bring up far better cocos2d specific label answers than typing in &#8216;<em>label</em>&#8216;. This article follows on from the <a href="http://abitofcode.com/2012/05/cocos2d-getting-started/">Cocos2d &#8211; Getting started</a> post.</p>
<ul>
<li><a href="http://abitofcode.com/2012/07/cocos2d-useful-tools/#tools_graphics">Graphics tools</a></li>
<li><a href="http://abitofcode.com/2012/07/cocos2d-useful-tools/#tools_spritesheets">Spritesheets and Physics</a></li>
<li><a href="http://abitofcode.com/2012/07/cocos2d-useful-tools/#tools_audio">Audio</a></li>
<li><a href="http://abitofcode.com/2012/07/cocos2d-useful-tools/#tools_layout">Layout</a></li>
<li><a href="http://abitofcode.com/2012/07/cocos2d-useful-tools/#tools_animation">Animation</a></li>
<li><a href="http://abitofcode.com/2012/07/cocos2d-useful-tools/#tools_utils">Utilities</a></li>
</ul>
<p><a name="tools_graphics"></a></p>
<h2 style="clear:both">Graphics tools</h2>
<h3>Particle Designer</h3>
<p><a href="http://particledesigner.71squared.com/"><img class="alignleft size-full" title="Particle Designer" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_PD.jpg" alt="" width="128" height="128" /></a> <strong>Paid app</strong> available from the <a href="http://particledesigner.71squared.com/">Particle designer site</a>. 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&#8217;ve finished you simply select the embedded texture option, save out as a cocos2d plist and add it to your project. </p>
<p>For a plist saved out as <em>myParticleSystem.plist</em> get your particle effect to appear in your project using the following code;</p>

<div class="wp_codebox"><table><tr id="p94829"><td class="code" id="p948code29"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// 1. Create a particle emitter using the setting in the plist file. ARCH_OPTIMAL_PARTICLE_SYSTEM</span>
  <span style="color: #11740a; font-style: italic;">//    is a macro that picks the optimal particle system for the device you're running on.</span>
  CCParticleSystem <span style="color: #002200;">*</span>emitter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;myParticleSystem.plist&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 2. Add the particle system</span>
  <span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>emitter<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Particle designer has a random mode and also contains a library of shared emitters submitted by other users.<br />
<span id="more-948"></span></p>
<h3 style="clear:both">Glyph Designer</h3>
<p><a href="http://glyphdesigner.71squared.com/"><img class="alignleft size-full wp-image-1073" title="Glyph Designer" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_GD.jpg" alt="" width="128" height="128" /></a><strong>Paid app</strong> available from the <a href="http://glyphdesigner.71squared.com/">Glyph designer site</a>.If you have text being regularly updated in a game, CCLabelTTF is going to start hitting your performance. A solution is to create a bitmapped font atlas, a single texture that contains all the characters that you are going to need along with a data file that contains the coordinates of where those characters are located. Cocos2d provides a CCLabelBMFont class that reads the <em>fnt</em> file format and build up your text by copying the characters you need from the texture atlas you provide.<br />
Building these atlas and data files by hand would be very painful, Glyph designer makes creating the files very easy and you can preview the final font output in real time as you add effects like drop shadow, outline etc.</p>
<p>Once you&#8217;re happy with your font, export it as a .fnt file (Cocos2d Text format). Add the generated .fnt and .png file (generated at the same time) to your project and use the code below to get it to show.</p>

<div class="wp_codebox"><table><tr id="p94830"><td class="code" id="p948code30"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// 1. add the .fnt and .png generated by Glyph designer to your project</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 2. create a CCLabelBMFont label, specifying the initial text and the .fnt file</span>
  CCLabelBMFont <span style="color: #002200;">*</span>myLabel <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCLabelBMFont labelWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;hello world&quot;</span> fntFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;blob.fnt&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 3. Add it</span>
  <span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>myLabel<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// ... when you want to update the string use setString</span>
  <span style="color: #002200;">&#91;</span>myLabel setString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;This is an update!&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Only characters that are in your font atlas will be displayed</span></pre></td></tr></table></div>

<p>There&#8217;s no font alignment setting in Glyph designer, you need to handle that in cocos2d, for a single line of text it&#8217;s just a case of moving the anchor point.<br />
<div id="attachment_1118" class="wp-caption alignleft" style="width: 550px"><a href="http://abitofcode.com/wp-content/uploads/2012/07/Tools_GD_diag.jpg"><img src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_GD_diag.jpg" alt="" title="Font alignment" width="540" height="360" class="size-full wp-image-1118" /></a><p class="wp-caption-text">Font alignment</p></div></p>

<div class="wp_codebox"><table><tr id="p94831"><td class="code" id="p948code31"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// by default label is center aligned (a)</span>
  myLabel.anchorPoint <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0.5</span>, <span style="color: #2400d9;">0.5</span><span style="color: #002200;">&#41;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// left aligned (b)</span>
  myLabel.anchorPoint <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0.5</span><span style="color: #002200;">&#41;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// right aligned (c)</span>
  myLabel.anchorPoint <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">0.5</span><span style="color: #002200;">&#41;</span>;</pre></td></tr></table></div>

<p>Anchor points are not set using pixels or points but as a fraction of the contentSize. Right aligned for example <em>ccp(1.0, 0.5)</em>, the ccp is a macro shortcut for CGPointMake, the x value <em>1.0</em> indicates that we need the full width of the Label for our anchorPoints x position and the <em>0.5</em> y value gives us half of the labels height for the anchorPoints y position.</p>
<h3 style="clear:both">Photoshop</h3>
<p><a href="http://www.adobe.com/uk/products/photoshopfamily.html"><img class="alignleft size-full" title="Photoshop" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_PS.jpg" alt="" width="128" height="128" /></a><strong>Paid app</strong> available from the <a href="http://www.photoshop.com/">Adobe</a> site. The daddy of the digital art world, comes at a premium price but packed with features and with .PSD files being pretty much an industry standard, one that&#8217;s hard to be without. I&#8217;m still happy with CS3 but the rest of the world is up to CS6.</p>
<p>At it&#8217;s heart Cocos2d maps textures onto openGL geometry, these textures will likely start life as .png files in Photoshop or Gimp. When you create a sprite, CCSprite creates some geometry (two triangles) to map some texture data onto (an image) and calls addImage on a singleton object called CCTextureCache. The image is converted into a form that openGL can deal with efficiently and the filename is used as a reference. This means if you create a 100 sprites using the same image file, the texture is only created once and shared between all the sprite instances, saving memory and vastly speeding everything up.</p>
<p>Unless you need to save space in your bundle avoid jpg files, apart from the loss in quality the first thing Cocos2d does is convert them to .png files before loading them in as textures. Opening up CCtextureCache.m and looking in the addImage method (called by CCSprite initWithFile) should reveal the following;</p>

<div class="wp_codebox"><table><tr id="p94832"><td class="code" id="p948code32"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// Issue #886: TEMPORARY FIX FOR TRANSPARENT JPEGS IN IOS4</span>
  <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCConfiguration sharedConfiguration<span style="color: #002200;">&#93;</span> OSVersion<span style="color: #002200;">&#93;</span> &gt;<span style="color: #002200;">=</span> kCCiOSVersion_4_0<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;&amp;</span> 
          <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span>lowerCase hasSuffix<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;.jpg&quot;</span><span style="color: #002200;">&#93;</span> || <span style="color: #002200;">&#91;</span>lowerCase hasSuffix<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;.jpeg&quot;</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#41;</span> 
          <span style="color: #002200;">&#123;</span>
            <span style="color: #11740a; font-style: italic;">// convert jpg to png before loading the texture</span>
            ...</pre></td></tr></table></div>

<p>Images/Textures have so many more uses than simply decorating an app, they can be used to store data or create effects that could otherwise be processor intensive.</p>
<ul>
<li><a href="http://abitofcode.com/2011/07/building-arrays-with-photoshop/">Create data with Photoshop</a></li>
<li><a href="http://abitofcode.com/2011/07/irregular-touch-detection-when-cgrect-is-not-enough-part-1/">Irregular touch detection, when CGRect is not enough – part 1</a></li>
<li><a href="http://abitofcode.com/2011/07/simple-animated-depth-of-field-effect/">Simple interactive depth of field effect</a></li>
<li><a href="http://abitofcode.com/2012/06/building-a-depth-map-for-cocos2d-in-photoshop/">Building a depth map for cocos2d in Photoshop</a></li>
<li><a href="http://abitofcode.com/2012/04/ccrendertexture-category-percentage-complete/">CCRenderTexture category – percentage complete</a></li>
</ul>
<p>If you&#8217;re using Photoshop with bitmap art pressing CMD + K and setting nearest neighbour as Image interpolation will prevent your images getting antialiased during scaling.</p>
<h3 style="clear:both">Gimp &#8211; GNU Image Manipulation Program</h3>
<p><a href="http://www.gimp.org/"><img class="alignleft size-full" title="Gimp" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_GI.jpg" alt="" width="128" height="128" /></a><strong>Free</strong> app available from <a href="http://www.gimp.org/">here</a>. A freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages. </p>
<p>Assuming we&#8217;ve created a 480 x 320 .png image called background.png, we can display it in the center of the screen using the following e.g in the init method;</p>

<div class="wp_codebox"><table><tr id="p94833"><td class="code" id="p948code33"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// ask CCDirector for the screen dimension</span>
  CGSize size <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCDirector sharedDirector<span style="color: #002200;">&#93;</span> winSize<span style="color: #002200;">&#93;</span>;	        
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Create a CCSprite.</span>
  <span style="color: #11740a; font-style: italic;">// CCSprite derives from CCNode but adds the geometry (basically a billboard) that</span>
  <span style="color: #11740a; font-style: italic;">// we can slap our background.png image onto. Under the hood CCSprite passes the</span>
  <span style="color: #11740a; font-style: italic;">// image to the CCTextureCache, uses the filename to check if we've already loaded</span>
  <span style="color: #11740a; font-style: italic;">// this texture and if not adds the image into the texture cache.</span>
  CCSprite <span style="color: #002200;">*</span>background <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSprite spriteWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;background.png&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// position the background sprite which is anchored in the center, to </span>
  <span style="color: #11740a; font-style: italic;">// the center of the screen</span>
  background.position <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span>size.width<span style="color: #002200;">*</span><span style="color: #2400d9;">0.5</span>, size.height<span style="color: #002200;">*</span><span style="color: #2400d9;">0.5</span><span style="color: #002200;">&#41;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Add the sprite to the layer</span>
  <span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>background<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<h3 style="clear:both">Seashore</h3>
<p><a href="http://seashore.sourceforge.net/The_Seashore_Project/Download.html"><img class="alignleft size-full" title="Seashore" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_seashore.jpg" alt="" width="128" height="128" /></a><strong>Free</strong> app available from <a href="http://seashore.sourceforge.net/The_Seashore_Project/Download.html">here</a>. Steffen (@gaminghorror) recommended this native Mac OSX app that does away with any requirement for X11, I&#8217;ve only had a quick play but   it&#8217;s looking good and it also saves typing Gimp into google which is always a winner <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3 style="clear:both">ShipIt!</h3>
<p><a href="http://itunes.apple.com/gb/app/shipit!/id492043869?mt=12"><img class="alignleft size-full" title="ShipIt!" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_SI.jpg" alt="" width="128" height="128" /></a><strong>Paid </strong> app for creating retina and standard sized images. More useful for standard UIKit development, this app will take a retina image, add the @2 extension onto it and then create a standard sized image without the extension. </p>
<p>Cocos2d does not get on with the @2 extension as there are conflicts in some parts of the framework with apples approach to Retina. The Cocos2d director has a method <em>contentScaleFactor</em> that defines the relation between point and pixels. If it is 1, points and pixels are the same, but if it is 2 (like retina displays ) it means that every point has two pixels.</p>

<div class="wp_codebox"><table><tr id="p94834"><td class="code" id="p948code34"><pre class="objc" style="font-family:monospace;">  CCDirector <span style="color: #002200;">*</span>director <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCDirector sharedDirector<span style="color: #002200;">&#93;</span>;
  <span style="color: #a61390;">float</span> contentScaleFactor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>director contentScaleFactor<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>You enable retina assets in the CCDirector, I&#8217;ve changed it slightly here to only allow Retina mode if we&#8217;re not on an iPad.</p>

<div class="wp_codebox"><table><tr id="p94835"><td class="code" id="p948code35"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// Changed slightly to avoid Retina assets on the retina iPad</span>
  <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">!=</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span>
  <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> <span style="color: #002200;">!</span> <span style="color: #002200;">&#91;</span>director enableRetinaDisplay<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
       CCLOG<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Retina Display Not supported&quot;</span><span style="color: #002200;">&#41;</span>;    
  <span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p><a name="tools_spritesheets"></a></p>
<h2 style="clear:both">Spritesheets and Physics</h2>
<p>There are a number of tools available for handling texture atlases and physics data, Zwoptex was the original atlas creation tool and I used the online and offline version for a while until TexturePacker came along. I now  jump between TexturePacker and the SpriteHelper/LevelHelper combo depending on what I&#8217;m building.</p>
<p>To find out which is the best app for you, you really need to try them out. I&#8217;d previously avoided physics libraries like Box2d and Chipmunk as I&#8217;d only needed limited physics and could roll my own. After seeing some of the stuff Juraj at GameCollage was producing I wanted to play and around the same time <a href="http://www.mekanimo.net/">Mekanimo</a> announced a Mac beta. After having a number of emails ignored and not wanting to run a PC just to generate physical systems Mekanimo was dropped. Since then I&#8217;ve found LevelHelper and it&#8217;s really nice <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3 style="clear:both">TexturePacker</h3>
<p><a href="http://www.codeandweb.com/texturepacker"><img class="alignleft size-full" title="TexturePacker" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_TP.jpg" alt="" width="128" height="128" /></a><br />
<strong>Paid</strong> app available from the <a title="Texture Packer site" href="http://www.codeandweb.com/texturepacker">Texture Packer</a> site. The tool runs on the command line but also has a GUI, the benefit of this setup is that you can script the texture atlas creation into your build. You create a folder of images and configure the script to create the atlas using your settings, when a new image is added the build simply adds it into the texture atlas (spritsheet). If you use flash to animate, TexturePacker also has the ability to <a href="#tools_flash">output your animations to a SpriteSheet</a></p>
<ul>
<li><a href="http://www.codeandweb.com/blog/2011/05/11/xcode4-integration-tutorial-of-texturepacker-for-cocos2d-and-sparrow-framework/">Details of XCode4 integration of TexturePacker for Cocos2d can be found here</a></li>
</ul>
<p>For the best explanation by far why packing multiple images into one texture is important, watch the following video by <a href="http://www.codeandweb.com">Code&#8217;n'Web</a>;<br />
<iframe src="http://player.vimeo.com/video/44440528" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p>The website is packed full of <a href="http://www.codeandweb.com/texturepacker/tutorials">tutorials</a>, <a href="http://www.codeandweb.com/texturepacker/testimonials">testimonials</a> and <a href="http://www.codeandweb.com/texturepacker/features">information</a> and well worth a visit.</p>
<p>TexturePacker has come in useful in a wide rage of projects including UIKit and Flash based work, the CLI access means it&#8217;ll be staying in my toolkit for a long time to come. </p>
<p><strong>A quick example</strong></p>
<p>To use a spritesheet we need to create a <em>CCSpriteBatchNode</em>. First add some sprites into TexturePacker making a note of the filenames (and make them meaningful).<br />
<a href="http://abitofcode.com/wp-content/uploads/2012/07/Tools_TP_screen.jpg"><img src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_TP_screen.jpg" alt="" title="Creating a Spritesheet" width="610" height="386" class="aligncenter size-full wp-image-1146" /></a></p>
<p>Export the image (.png) and data (.plist) files from TexturePacker and add them to your project.</p>

<div class="wp_codebox"><table><tr id="p94836"><td class="code" id="p948code36"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// 1. Store all the coordinates, rotation info etc generated</span>
  <span style="color: #11740a; font-style: italic;">// by Texture packer. We use the filename as a key to find the</span>
  <span style="color: #11740a; font-style: italic;">// information for each sprites texture offset in the png.</span>
  <span style="color: #11740a; font-style: italic;">// CCSpriteFrameCache is a singleton.</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCSpriteFrameCache sharedSpriteFrameCache<span style="color: #002200;">&#93;</span> addSpriteFramesWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bob.plist&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 2. The batchnode will draw all the sprites within it in one</span>
  <span style="color: #11740a; font-style: italic;">// pass, all the sprites texture data must be contained within </span>
  <span style="color: #11740a; font-style: italic;">// the same .png file</span>
  CCSpriteBatchNode <span style="color: #002200;">*</span>myBatchNode <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSpriteBatchNode batchNodeWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bob.png&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 3. Add a sprite to the batchnode, we use spriteWithSpriteFrameName</span>
  <span style="color: #11740a; font-style: italic;">// NOT spriteWithFile as the texture data will be provided by the </span>
  <span style="color: #11740a; font-style: italic;">// batchnode. The filename is only used here as a key into the</span>
  <span style="color: #11740a; font-style: italic;">// CCSpriteFrameCache to find the right bit of the texture</span>
  CCSprite <span style="color: #002200;">*</span>head <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSprite spriteWithSpriteFrameName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;head.png&quot;</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>myBatchNode addChild<span style="color: #002200;">:</span>head<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// ... add more sprites</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 4. We now have sprites being drawn in the batchnode but the </span>
  <span style="color: #11740a; font-style: italic;">// batchnode itself is not being drawn, add it to the layer.</span>
  <span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>myBatchNode<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<h3 style="clear:both">Physics Editor</h3>
<p><a href="http://www.codeandweb.com/physicseditor"><img class="alignleft size-full" title="Physics Editor" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_PE.jpg" alt="" width="128" height="128" /></a><br />
<strong>Paid </strong> app available from <a href="http://www.codeandweb.com/physicseditor">here</a>. The only app in the list I do not own but as it pairs with TexturePacker thought it deserved a mention.</p>
<p>Makes creating collision shapes very simple;</p>
<ol>
<li>Drop shape</li>
<li>Press AutoTrace</li>
<li>Export to your game engine</li>
</ol>
<p>The <a href="http://www.codeandweb.com/physicseditor/tutorials">Physics editor website </a>contains a number of tutorials. </p>
<h3 style="clear:both">SpriteHelper</h3>
<p><a href="http://www.spritehelper.org/"><img class="alignleft size-full" title="SpriteHelper" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_SH.jpg" alt="" width="128" height="128" /></a><br />
<strong>Paid</strong> available from <a href="http://itunes.apple.com/us/app/spritehelper/id416068717?mt=12">Mac app store</a> or directly from the <a href="http://www.spritehelper.org/">Spritehelper</a> website. I bought SpriteHelper and LevelHelper when they first came out, used them for a couple of days and then reverted back to TexturePacker. I didn&#8217;t really see the point in SpriteHelper and felt it was a little tightly coupled to LevelHelper. Having played with the recent beta I have a feeling they are going to become my tools of choice for physics. Creating complex systems is a case of drag and drop and the tools generate the code required to run the systems. </p>
<p>Another nice feature of SpriteHelper is it can directly import PSD files <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/g-WzP5ESDlc?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<h3 style="clear:both">LevelHelper</h3>
<p><a href="http://www.levelhelper.org/"><img class="alignleft size-full" title="LevelHelper" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_LH.jpg" alt="" width="128" height="128" /></a><br />
<strong>Paid</strong> available from <a href="http://itunes.apple.com/gb/app/levelhelper/id421740820?mt=12">Mac app store</a> or directly from the <a href="http://www.levelhelper.org/">LevelHelper</a> website. From the website there are a number of <a href="http://www.levelhelper.org/?page_id=2144">Purchase options</a> including a bundle with Spritehelper.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/nX-CqswS3TE?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>The recent update in the beta has meant I need to rebuild my example files so I&#8217;ll post the example code up next week. There are <a href="http://www.levelhelper.org/?cat=5">full game tutorials</a> on the site and Ray has a great 4 part article on <a href="http://www.raywenderlich.com/6929/how-to-make-a-game-like-jetpack-joyride-using-levelhelper-spritehelper-part-1">building a game like Jetpack joyride</a> using LevelHelper.</p>
<h3 style="clear:both">Zwoptex</h3>
<p><a href="http://zwopple.com/zwoptex/"><img class="alignleft size-full" title="Zwoptex" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_ZW.jpg" alt="" width="128" height="128" /></a><br />
<strong>Paid</strong> app available from the <a href="http://zwopple.com/zwoptex/">Zwoptex site</a>. Great app packed with features, I still own a copy but TexturePackers build integration and CLI was too good to pass on.</p>
<p>The free Flash version is still available from the bottom right of their website but it may not be up to date.</p>
<p>There&#8217;s a great <a href="http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d">animation tutorial</a> that uses zwoptex over on Ray Wenderlich&#8217;s site.</p>
<p><a name="tools_audio"></a></p>
<h2 style="clear:both">Audio</h2>
<p>There are some great tools for handling audio, before firing them up though it may be worth taking a little time to get acquainted with the audio formats and best practices for sound on iOS;</p>
<ul>
<li><a href="http://gamua.com/blog/2010/06/sound-on-ios-best-practices/">Sound on iOS: Best Practices</a></li>
<li><a href="http://www.raywenderlich.com/233/audio-101-for-iphone-developers-converting-and-recording">Audio 101 for iPhone Developers: Converting and Recording</a></li>
</ul>
<h3 style="clear:both">CFXR</h3>
<p><a href="http://thirdcog.eu/apps/cfxr/"><img class="alignleft size-full" title="CFXR" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_CF.jpg" alt="" width="128" height="128" /></a><br />
<Strong>Free</strong> Mac port of <a href="http://www.drpetter.se/project_sfxr.html">SFXR</a> available from the <a href="http://thirdcog.eu/apps/cfxr/">CFXR</a> site. A great tool for creating simple sound effects, I&#8217;ve had issues getting the exported sound to match the previewed sound so used Audacity instead (below) to record them.</p>
<h3 style="clear:both">Audacity</h3>
<p><a href="http://audacity.sourceforge.net/"><img class="alignleft size-full" title="Audacity" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_AU.jpg" alt="" width="128" height="128" /></a><br />
Audacity is a <strong>free</strong>, easy-to-use and multilingual audio editor and recorder for Windows, Mac OS X, GNU/Linux and other operating systems. You can download it from the <a href="http://audacity.sourceforge.net/">Audacity site</a>. A great app for trimming, manipulating, recording sounds for use in apps.</p>
<p>Keeping your effects short and using the same format (little endian, 16 bit, 22kHz CAFF files) can help reduce the amount of work the audio system has to do.</p>
<p><strong>Converting a file </strong></p>
<div class="terminal">
# creates mysound.caf (little endian, 16 bit, 22kHz)<br />
afconvert -f caff -d LEI16@22050 mysound.wav
</div>
<p>The <a href="http://gamua.com/blog/2010/06/sound-on-ios-best-practices/">best practices link </a> takes this a step further with a script for converting a directory of wav files at once.</p>
<p>The iPhone can only hardware decode one mp3 at a time so you would usually use the mp3 format for your background music and CAFF files for your sound effects. The following samples handle audio in a very simple synchronous approach, Rod Strougo and Ray Wenderlich have a nice approach to asynchronous audio in their book <a href="http://www.amazon.co.uk/gp/product/0321735625/ref=as_li_qf_sp_asin_il?ie=UTF8&#038;tag=abitofcodecom-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=0321735625">Learning Cocos2D: A Hands-on Guide to Building IOSGames with Cocos2D, Box2D, and Chipmunk (Addison-Wesley Learning Series)</a>.</p>
<p><strong>Playing a sound effect</strong></p>

<div class="wp_codebox"><table><tr id="p94837"><td class="code" id="p948code37"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// The SimpleAudioEngine is another singleton, grab a reference to it </span>
  <span style="color: #11740a; font-style: italic;">// and preload the wav file mysound.wav. This could be done in a loading </span>
  <span style="color: #11740a; font-style: italic;">// scene. The sound is stored and referenced by the filename</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SimpleAudioEngine sharedEngine<span style="color: #002200;">&#93;</span> preloadEffect<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;mysound.wav&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Play the sound when required using the filename to identify the</span>
  <span style="color: #11740a; font-style: italic;">// sound, if there's a preloaded version it will use that version.</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SimpleAudioEngine sharedEngine<span style="color: #002200;">&#93;</span> playEffect<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;mysound.wav&quot;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p><strong>Playing background music</strong></p>

<div class="wp_codebox"><table><tr id="p94838"><td class="code" id="p948code38"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// Preload the background music. This could be done in an earlier scene</span>
  <span style="color: #11740a; font-style: italic;">// [SimpleAudioEngine sharedEngine] is a Singleton and will be available</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SimpleAudioEngine sharedEngine<span style="color: #002200;">&#93;</span> preloadBackgroundMusic<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Beelzeboss.mp3&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Play and loop the background music </span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SimpleAudioEngine sharedEngine<span style="color: #002200;">&#93;</span> playBackgroundMusic<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Beelzeboss.mp3&quot;</span> loop<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// When you're done with it, stop it and unload it</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SimpleAudioEngine sharedEngine<span style="color: #002200;">&#93;</span> stopBackgroundMusic<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SimpleAudioEngine sharedEngine<span style="color: #002200;">&#93;</span> unloadEffect<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Beelzeboss.mp3&quot;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>If you need to do something a little more complex with audio in Cocos2d look at the CDAudioManager (CocosDenshion NOT compact disk) written by Steve Oldmeadow and also distributed along with cocos2d. Here Lam of FancyRatStudios.com shows it running as an audio meter;</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/GgORVtsyEuU?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p><a name="tools_layout"></a></p>
<h2 style="clear:both">Layout</h2>
<h3 style="clear:both">Tiled</h3>
<p><a href="http://www.mapeditor.org/"><img class="alignleft size-full" title="Tiled" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_TI.jpg" alt="" width="128" height="128" /></a><br />
<strong>Free</strong> app available from the <a href="http://www.mapeditor.org/">Tiled map editor site</a>.<br />
Tilemaps allow the creation of larger levels by creating them out of smaller tiles. They are far more efficient than creating and scrolling large bitmap images. </p>
<p>There&#8217;s a great set of tutorials <a href="http://www.raywenderlich.com/1163/how-to-make-a-tile-based-game-with-cocos2d">How To Make a Tile-Based Game with Cocos2D</a> over at <a href="http://www.raywenderlich.com">Ray Wenderlich&#8217;s site</a></p>
<p><em>From the tiled site</em><br />
Tiled is a general purpose tile map editor. It&#8217;s built to be easy to use, yet flexible enough to work with varying game engines, whether your game is an RPG, platformer or Breakout clone. Tiled is free software and written in C++, using the Qt application framework. The main features in a nutshell:</p>
<ul>
<li>General purpose tile map editor with XML-based map format</li>
<li>Supports orthogonal and isometric maps</li>
<li>Custom objects can be placed with pixel precision</li>
<li>Full undo/redo and copy/paste support</li>
<li>Add custom properties to tiles, layers, objects or the map</li>
<li>Automatically reloads tilesets when changed externally</li>
<li>Resize or offset your tile map later as needed</li>
<li>Efficient tile editing tools like stamp and fill brushes</li>
<li>Supports input/output plugins to open and save files in custom formats</li>
</ul>
<p><strong>Example file <em>forest.tmx</em> generated by Tiled</strong></p>

<div class="wp_codebox"><table><tr id="p94839"><td class="code" id="p948code39"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">orientation</span>=<span style="color: #ff0000;">&quot;orthogonal&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000066;">tilewidth</span>=<span style="color: #ff0000;">&quot;32&quot;</span> <span style="color: #000066;">tileheight</span>=<span style="color: #ff0000;">&quot;32&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tileset</span> <span style="color: #000066;">firstgid</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dg_grounds32&quot;</span> <span style="color: #000066;">tilewidth</span>=<span style="color: #ff0000;">&quot;32&quot;</span> <span style="color: #000066;">tileheight</span>=<span style="color: #ff0000;">&quot;32&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;dg_grounds32.png&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;288&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;608&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Tile Layer 1&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;15&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;data</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;base64&quot;</span> <span style="color: #000066;">compression</span>=<span style="color: #ff0000;">&quot;zlib&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   eJzjZWBg4B2C2JYApqZZpJhJrFnEmEmsWnLUUTsOSFE/VM3DZSa90gyleYQacT7QGAD6gB49
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/data<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Here <em>dg_grounds32.png</em> is the image that provides the tile textures and the data element is compressed data that describes the tile layout. </p>
<p>Multiple tilemap layers can be created within the same tmx file and layers can be object layers or Tile layers. Tile layers are visual, object layers could be used to describe properties of each grid square.</p>

<div class="wp_codebox"><table><tr id="p94840"><td class="code" id="p948code40"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// Load Tilemap data from the tmx file into a CCTMXTileMap. The .png file</span>
  <span style="color: #11740a; font-style: italic;">// containing the tile textures is referenced within the .tmx file</span>
  CCTMXTiledMap <span style="color: #002200;">*</span>mapNode <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCTMXTiledMap tiledMapWithTMXFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;forest.tmx&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Add the tile map to the layer, that's it. Done :)        </span>
  <span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>mapNode<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<h3 style="clear:both">Inkscape</h3>
<p><a href="http://inkscape.org/"><img class="alignleft size-full" title="Inkscape" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_IN.jpg" alt="" width="128" height="128" /></a><br />
<strong>Free</strong> app available from <a href="http://inkscape.org/">Inkscape site</a>. Inkscape is an open source vector graphics editor similar to Adobe&#8217;s illustrator and uses the Scaleable Vector Graphics (SVG) file format.<br />
There&#8217;s no support in cocos2d for SVG as a graphic format but we could use it as a data format to hold level layout information especially for physics games. This was the approach that LevelSVG took before it was removed from sale.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/fUvqEh2tlCQ?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>The geometry can be laid out using the simple drawing tools. If you need to add a custom property to an object, select it then press Control + SHIFT + x to bring up the XML editor. Below I&#8217;ve created a new property called myProperty with a value myValue.<br />
<a href="http://abitofcode.com/wp-content/uploads/2012/07/Tools_IN_screen.jpg"><img src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_IN_screen.jpg" alt="" title="Using inkscape to create level data" width="610" height="790" class="aligncenter size-full wp-image-1184" /></a></p>
<p>Saving the file as an Inkscape SVG file will include the custom data we added to our objects e.g myProperty in the output SVG file. This file can be parsed using any number of <a href="http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project">XML parsers</a>.</p>

<div class="wp_codebox"><table><tr id="p94841"><td class="code" id="p948code41"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;svg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;g</span></span>
<span style="color: #009900;">     <span style="color: #000066;">inkscape:label</span>=<span style="color: #ff0000;">&quot;Layer 1&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">inkscape:groupmode</span>=<span style="color: #ff0000;">&quot;layer&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;layer1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rect</span></span>
<span style="color: #009900;">       <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;fill:none;stroke:#000000;stroke-opacity:1&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;rect3755&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;391.42856&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;208.57143&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;54.285713&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;78.076469&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">myProperty</span>=<span style="color: #ff0000;">&quot;myValue&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/g<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/svg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Control + SHIFT + e will bring up the export Bitmap dialog, selecting the Page button and then Export will output the layout you&#8217;ve created as a bitmap image which could then be used as a layout guide in Photoshop to draw over.</p>
<h3 style="clear:both">CocosBuilder</h3>
<p><strong>** Update **</strong> There&#8217;s a pre alpha of the new Animation editor <a href="http://cocosbuilder.com/?p=164">available here</a>, help out the developer by having a play and giving feedback <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://cocosbuilder.com/"><img class="alignleft size-full" title="CocosBuilder" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_CB.jpg" alt="" width="128" height="128" /></a><br />
<strong>Free</strong> app available from the <a href="http://cocosbuilder.com/">CocosBuilder site</a>.</p>
<p><em>From the CocosBuilder site</em><br />
CocosBuilder is a free tool for graphically laying out sprites, layers and scenes for Cocos2D iPhone and Mac. It’s ideal for quickly and accurately creating menus and other parts of the interface, but can also be used to create levels, particle systems or any other kind of Cocos2D node graphs. CocosBuilder is released as open source under MIT license.</p>
<p>The latest development only supports Cocos2d v2.0 but there is an older version 1.0 that supports cocos2d v1.</p>
<p>You build up your layout in CocosBuilder visually and then save the layout as a .ccb file, this is a .plist file that represents the nodeGraph you have built. This file is parsed by some helper files you add to your project (CCBReader.h, CCBReader.m). </p>
<p>You can associate objects in the CocosBuilder editor with bespoke classes that derive from the object you have added. e.g if you add a CCLayer and need to add some functionality, create a myLayer class that extends CCLayer and add your own code. Don&#8217;t override the init method instead use the didLoadFromCCB method. You can also link objects in your nodeGraph (e.g a CCSprite) to a member variable, and add callbacks to buttons.</p>
<p>There is documentation included in the distribution, and an <a href="http://cocosbuilder.com/?page_id=11">example project</a> you can download.</p>
<p>1. Open and run the example project <strong>in XCode</strong> to see the sort of effects you can get<br />
2. Right click the .ccb file under resources <strong>in Xcode</strong> and open with external editor to see the nodeGraph in CocosBuilder. If you have both versions of CocosBuilder on your system, open the v1.0 version first and then right-click and select open.</p>
<p><a href="http://abitofcode.com/wp-content/uploads/2012/07/Tools_CB_screen.jpg"><img src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_CB_screen.jpg" alt="" title="Tools_CB_screen" width="610" height="417" class="aligncenter size-full wp-image-1198" /></a></p>

<div class="wp_codebox"><table><tr id="p94842"><td class="code" id="p948code42"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>methodname
  <span style="color: #11740a; font-style: italic;">// 1. Add the CCBReader.h and CCBReader.m files to the project</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 2. Add the CCBReader import</span>
  <span style="color: #6e371a;">#import &quot;CCBReader.h&quot;</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 3. Import any assets you've used, the files are relative to the .ccb file so easiest to create </span>
  <span style="color: #11740a; font-style: italic;">// the file in your resources directory and add the images to your project as you add them</span>
  <span style="color: #11740a; font-style: italic;">// in the .ccb file</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 4. Load the scene from the example.ccb file</span>
  CCScene<span style="color: #002200;">*</span> scene <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCBReader sceneWithNodeGraphFromFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;example.ccb&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 5. Start the first scene in AppDelegate</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCDirector sharedDirector<span style="color: #002200;">&#93;</span> runWithScene<span style="color: #002200;">:</span> scene<span style="color: #002200;">&#93;</span>;
&nbsp;
or
&nbsp;
  <span style="color: #11740a; font-style: italic;">// 5. Push a new scene if this is not the first scene</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCDirector sharedDirector<span style="color: #002200;">&#93;</span> replaceWithScene<span style="color: #002200;">:</span> scene<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>In the example project, the main Layer has a custom class associated with it <em>HelloCocosBuilder</em>. A button with a selector <em>pressedButton:</em> added to it and a sprite linked to a member variable named <em>sprtBurst</em>.<br />
I&#8217;ve included the .h and .m files below;</p>

<div class="wp_codebox"><table><tr id="p94843"><td class="code" id="p948code43"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  HelloCocosBuilder.h</span>
<span style="color: #11740a; font-style: italic;">//  CocosBuilderTest</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span>
<span style="color: #6e371a;">#import &quot;cocos2d.h&quot;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// This is a custom class for a layer specified by setting the custom</span>
<span style="color: #11740a; font-style: italic;">// class attribute in CocosBuilder for the root node.</span>
<span style="color: #11740a; font-style: italic;">// It is loaded from AppDelegate.m</span>
&nbsp;
<span style="color: #a61390;">@interface</span> HelloCocosBuilder <span style="color: #002200;">:</span> CCLayer
<span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// These instance variables are defined in the CocosBuilder file</span>
    <span style="color: #11740a; font-style: italic;">// (example.ccb) and automatically assigned by CCBReader</span>
    CCSprite<span style="color: #002200;">*</span> sprtBurst;
    CCSprite<span style="color: #002200;">*</span> sprtIcon;
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p94844"><td class="code" id="p948code44"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  HelloCocosBuilder.m</span>
<span style="color: #11740a; font-style: italic;">//  CocosBuilderTest</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;HelloCocosBuilder.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@implementation</span> HelloCocosBuilder
&nbsp;
<span style="color: #11740a; font-style: italic;">// This method is called right after the class has been instantiated</span>
<span style="color: #11740a; font-style: italic;">// by CCBReader. Do any additional initiation here. If no extra</span>
<span style="color: #11740a; font-style: italic;">// initialization is needed, leave this method out.</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> didLoadFromCCB
<span style="color: #002200;">&#123;</span>    
    <span style="color: #11740a; font-style: italic;">// Start rotating the burst sprite</span>
    <span style="color: #002200;">&#91;</span>sprtBurst runAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>CCRepeatForever actionWithAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>CCRotateBy actionWithDuration<span style="color: #002200;">:</span>5.0f angle<span style="color: #002200;">:</span><span style="color: #2400d9;">360</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// This method is set as an attribute to the CCMenuItemImage in</span>
<span style="color: #11740a; font-style: italic;">// CocosBuilder, and automatically set up to be called when the</span>
<span style="color: #11740a; font-style: italic;">// button is pressed.</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> pressedButton<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender
<span style="color: #002200;">&#123;</span>    
    <span style="color: #11740a; font-style: italic;">// Stop all runnint actions for the icon sprite</span>
    <span style="color: #002200;">&#91;</span>sprtIcon stopAllActions<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Reset the rotation of the icon</span>
    sprtIcon.rotation <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Rotate the sprtIcon 360 degrees</span>
    <span style="color: #002200;">&#91;</span>sprtIcon runAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>CCRotateBy actionWithDuration<span style="color: #002200;">:</span>1.0f angle<span style="color: #002200;">:</span><span style="color: #2400d9;">360</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>There&#8217;s also work on adding an Action/Animation editor to CocosBuilder http://www.cocos2d-iphone.org/forum/topic/32775 <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a name="tools_animation"></a></p>
<h2 style="clear:both">Animation</h2>
<h3>Spriter</h3>
<p><strong>Coming soon</strong> &#8211; Spriter is a <a href="http://www.kickstarter.com/projects/539087245/spriter">Kickstarter</a> project that the Cocos2d community got <a href="http://www.cocos2d-iphone.org/forum/topic/30781">wind of</a> and pushed for cocos2d support and a Mac version.<br />
<iframe src="http://www.kickstarter.com/projects/539087245/spriter/widget/video.html" frameborder="0" width="480" height="360"></iframe> </p>
<p><em>From the Kickstarter site</em><br />
Spriter is a powerful animation tool for creating highly detailed 2d real-time game characters and effects in an intuitive, visual editor. The characters are saved to a format that allows game engines to produce higher quality visuals, while also using less video ram, and requiring less disk space per frame than traditional 2d sprite animation. </p>
<p>   Spriter also provides several game specific features like collision boxes, and sound effect triggering, and saves to an open format that will be useable across many different game engines and platforms. </p>
<p>Feature list<br />
<a href="http://dl.dropbox.com/u/1013446/Spriter%20Releases/features/Containers.pdf">features</a></p>
<p>@TacoGraveyard put a <a href="https://github.com/talentless/spriter-cocos2d">Cocos2d test project</a> together that implemented the original rough file structure. You can see the results here.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/mtX0a26voWU?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p><a name="tools_flash"></a></p>
<h3 style="clear:both">Flash</h3>
<p><a href="http://www.adobe.com/uk/products/flash.html"><img class="alignleft size-full" title="Flash" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_FL.jpg" alt="" width="128" height="128" /></a><br />
<strong>Paid</strong> app available from the <a href="http://www.adobe.com/uk/products/flash.html">Adobe</a> site. A great animation and prototyping tool, I also use it to walk through animations sequences that I need to convert over to code. </p>
<p>For a short time there was a working library &#8211; <em>MonkSwf</em> that enabled you to load animated swf&#8217;s into Cocos2d, unfortunately it was removed after a legal threat from somewhere <img src='http://abitofcode.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>On the plus side, TexturePacker (see Graphics tools) has a great swf import feature</p>
<p><a href="http://abitofcode.com/wp-content/plugins/download-monitor/download.php?id=14">Dog animation - fla and swf file</a><br />
<a href="http://abitofcode.com/wp-content/plugins/download-monitor/download.php?id=15">Dog animation - png and plist from TexturePacker</a></p>
<p><a href="http://abitofcode.com/wp-content/uploads/2012/07/Tools_FL_screen.jpg"><img src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_FL_screen.jpg" alt="" title="Tools_FL_screen" width="610" height="372" class="aligncenter size-full wp-image-1213" /></a></p>
<p>It converts each animated frame to an image and it also appears to only import the image data for those frames that change.</p>
<p><strong>Animating example</strong></p>

<div class="wp_codebox"><table><tr id="p94845"><td class="code" id="p948code45"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// Cache the animation frames. i.e for each 'filename' where</span>
  <span style="color: #11740a; font-style: italic;">// is the image data located in the texture. Has it been rotated</span>
  <span style="color: #11740a; font-style: italic;">// or trimmed as it was placed into the texture atlas (spritesheet)</span>
  <span style="color: #11740a; font-style: italic;">// we'll need this information to restore it to its original form.</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCSpriteFrameCache sharedSpriteFrameCache<span style="color: #002200;">&#93;</span> addSpriteFramesWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dog.plist&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// create a batchnode to hold the dog animation texture, we'll add our </span>
  <span style="color: #11740a; font-style: italic;">// animated dog sprites into this node.</span>
  CCSpriteBatchNode <span style="color: #002200;">*</span>dogSheet <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSpriteBatchNode batchNodeWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dog.png&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// add the dogSheet :p to the layer</span>
 <span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>dogSheet<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// loop through the animation frames and add each frame to an array.</span>
  <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> <span style="color: #002200;">*</span>dogAnimFrames <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span style="color: #400080;">NSMutableArray</span></a> array<span style="color: #002200;">&#93;</span>;
  <span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i &lt;<span style="color: #002200;">=</span> <span style="color: #2400d9;">35</span>; <span style="color: #002200;">++</span>i<span style="color: #002200;">&#41;</span>  
  <span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// [NSString stringWithFormat:@&quot;dog.swf/00%02d&quot;, i] builds the key </span>
    <span style="color: #11740a; font-style: italic;">// for each frame in the .plist</span>
    <span style="color: #002200;">&#91;</span>dogAnimFrames addObject<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCSpriteFrameCache sharedSpriteFrameCache<span style="color: #002200;">&#93;</span> spriteFrameByName<span style="color: #002200;">:</span>
                               <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dog.swf/00%02d&quot;</span>, i<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#125;</span>        
&nbsp;
  <span style="color: #11740a; font-style: italic;">// create the animation object</span>
  CCAnimation <span style="color: #002200;">*</span>dogAnim <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCAnimation animationWithFrames<span style="color: #002200;">:</span>dogAnimFrames delay<span style="color: #002200;">:</span>0.05f<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Do we use directly ------&gt;</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// a) We could create a looped animation using CCRepeatForever, this can then be</span>
  <span style="color: #11740a; font-style: italic;">// run on the sprite.</span>
  <span style="color: #a61390;">id</span> dogAction <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCRepeatForever actionWithAction<span style="color: #002200;">:</span>
                   <span style="color: #002200;">&#91;</span>CCAnimate actionWithAnimation<span style="color: #002200;">:</span>dogAnim restoreOriginalFrame<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// &lt;-- OR use cached version ------&gt;</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// b) we could set up all of this in advance and add the animation to </span>
  <span style="color: #11740a; font-style: italic;">// a CCAnimationCache. When we need a copy of the animation to use on </span>
  <span style="color: #11740a; font-style: italic;">// a sprite we call animationByName on the Animation cache singleton</span>
  <span style="color: #11740a; font-style: italic;">// As the animation cache is a singleton, these animation are available </span>
  <span style="color: #11740a; font-style: italic;">// to all scenes</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCAnimationCache sharedAnimationCache<span style="color: #002200;">&#93;</span> addAnimation<span style="color: #002200;">:</span>dogAnim name<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dogAnimation&quot;</span><span style="color: #002200;">&#93;</span>; 
  <span style="color: #a61390;">id</span> cachedAnim <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCAnimationCache sharedAnimationCache<span style="color: #002200;">&#93;</span> animationByName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dogAnimation&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #a61390;">id</span> dogAction <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCRepeatForever actionWithAction<span style="color: #002200;">:</span>
                <span style="color: #002200;">&#91;</span>CCAnimate actionWithAnimation<span style="color: #002200;">:</span>cachedAnim restoreOriginalFrame<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// &lt;------ end cached version</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Either way we now have a dogAction animation that can be run on</span>
  <span style="color: #11740a; font-style: italic;">// a sprite.</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// create the dog sprite that we'll animate</span>
  CCSprite <span style="color: #002200;">*</span>dog <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSprite spriteWithSpriteFrameName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dog.swf/0000&quot;</span><span style="color: #002200;">&#93;</span>;        
  <span style="color: #002200;">&#91;</span>dog setPosition<span style="color: #002200;">:</span> ccp<span style="color: #002200;">&#40;</span>size.width<span style="color: #002200;">/</span><span style="color: #2400d9;">2</span>, size.height<span style="color: #002200;">/</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>dogSheet addChild<span style="color: #002200;">:</span>dog<span style="color: #002200;">&#93;</span>;              
&nbsp;
  <span style="color: #11740a; font-style: italic;">// run the looping animation 'dogAction' on our sprite</span>
  <span style="color: #002200;">&#91;</span>dog runAction<span style="color: #002200;">:</span>dogAction<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p><a name="tools_utils"></a></p>
<h2 style="clear:both">Utilities</h2>
<h3 style="clear:both">Hue Go Lite</h3>
<p><a href="http://itunes.apple.com/gb/app/huego-lite/id468963923?mt=12"><img class="alignleft size-full" title="Hue Go Lite" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_HG.jpg" alt="" width="128" height="128" /></a><strong>Paid and lite</strong> version available from the <a href="http://itunes.apple.com/gb/app/huego-lite/id468963923?mt=12">Mac app store</a>. Useful utility that  gives you a color picker to use anywhere across your desktop, I use the lite version to grab colours without having to fire up Photoshop.</p>

<div class="wp_codebox"><table><tr id="p94846"><td class="code" id="p948code46"><pre class="objc" style="font-family:monospace;">  <span style="color: #11740a; font-style: italic;">// select the color in Hue Go and use the copy as RGB </span>
  <span style="color: #11740a; font-style: italic;">// option</span>
  mysprite.color <span style="color: #002200;">=</span> ccc3<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">180</span>,<span style="color: #2400d9;">104</span>,<span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;</pre></td></tr></table></div>

<h3 style="clear:both">Icons</h3>
<p><a href="http://itunes.apple.com/gb/app/icons/id413612688?mt=12"><img class="alignleft size-full" title="Icons" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_IC.jpg" alt="" width="128" height="128" /></a><br />
<Strong>Paid</strong> app available from the <a href="http://itunes.apple.com/gb/app/icons/id413612688?mt=12">app store</a>. Not really a Cocos2d specific tool but given the time this saves me I thought it deserved a mention.<br />
Simply drag your 512&#215;512 icon onto the app, preview it in all sizes and when happy export all for immediate use. Simples <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3 style="clear:both">TotalTerminal</h3>
<p><a href="http://totalterminal.binaryage.com/"><img class="alignleft size-full" title="TotalTerminal" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_TT.jpg" alt="" width="128" height="128" /></a><br />
<strong>Free</strong> <a href="http://totalterminal.binaryage.com/">TotalTerminal</a> &#8211; a system-wide terminal available on a hot-key.<br />
Press Control + ` and a terminal appears, Lovely!</p>
<div style="clear:both" />
<strong>Some useful shortcuts;</strong><br />
Command + T -> Create a new tab in the terminal<br />
Command + Shift + ] -> Go to next tab on the right<br />
Command + Shift + [ -> Go to next tab on the left<br />
Tab -> path completion<br />
Drag a folder from finder to a terminal to get the path<br />
In the terminal type Control + r to bring up a reverse-i-search</p>
<div class="terminal">
# close the current tab<br />
>exit</p>
<p># go to users home directory<br />
>cd ~</p>
<p># go to simulator directory<br />
cd ~/Library/Application\ Support/iPhone\ Simulator/</p>
<p># open a finder window to the current terminal directory  location<br />
>open .
</p></div>
<h3 style="clear:both">Dash</h3>
<p><a href="http://itunes.apple.com/us/app/dash/id458034879?ls=1&amp;mt=12"><img class="alignleft size-full" title="Dash" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_DA.jpg" alt="" width="128" height="128" /></a><strong>Paid</strong> Dash &#8211; Snippet manager, Documentation browser is available from the <a href="http://itunes.apple.com/us/app/dash/id458034879?ls=1&amp;mt=12">Mac app store</a>. Further information available at the <a href="http://kapeli.com/dash/">Dash site</a>.</p>
<p>I Previously mentioned this in the <a href="http://abitofcode.com/2012/05/cocos2d-getting-started/">Cocos2d getting started</a> post when it was a free app, it has since adopted the nagware approach. Still very useful but one app where it didn&#8217;t pay to be an early adopter/promoter <img src='http://abitofcode.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h2 style="Clear:both">Development</strong></p>
<h3 style="clear:both">XCode</h3>
<p><a href="http://itunes.apple.com/gb/app/xcode/id497799835?mt=12"><img class="alignleft size-full" title="XCode" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_XC.jpg" alt="" width="128" height="128" /></a><br />
<a href="http://itunes.apple.com/gb/app/xcode/id497799835?mt=12">XCode</a> available from the Mac App store.<br />
Grabbing screenshots while playing a game can be a lot harder than the UIKit equivalent, having someone play the game while someone else uses Organizer (Command + Shift + 2) to grab screenshots, will probably get better results than trying to play the game and press both buttons at the same time.</p>
<h3 style="clear:both">Cocos2d</h3>
<p><a href="http://www.cocos2d-iphone.org/download"><img class="alignleft size-full" title="Cocos2d" src="http://abitofcode.com/wp-content/uploads/2012/07/Tools_CO.jpg" alt="" width="128" height="128" /></a><br />
<a href="http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:lesson_1._install_test">Installing the developer tools and Cocos2d</a></p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/GCSGOpECirw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2012/07/cocos2d-useful-tools/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2012/07/cocos2d-useful-tools/</feedburner:origLink></item>
		<item>
		<title>Building a depth map for cocos2d in Photoshop</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/cZzeTeZ7Cfc/</link>
		<comments>http://abitofcode.com/2012/06/building-a-depth-map-for-cocos2d-in-photoshop/#comments</comments>
		<pubDate>Sun, 24 Jun 2012 23:48:56 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=496</guid>
		<description><![CDATA[After the Create data with Photoshop and Irregular touch detection, when CGRect is not enough – part 1 articles last July I started to write a follow up showing another use of the raw data format. I&#8217;ve just found the &#8230; <a href="http://abitofcode.com/2012/06/building-a-depth-map-for-cocos2d-in-photoshop/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>After the <a href="http://abitofcode.com/2011/07/building-arrays-with-photoshop/">Create data with Photoshop</a> and <a href="http://abitofcode.com/2011/07/irregular-touch-detection-when-cgrect-is-not-enough-part-1/">Irregular touch detection, when CGRect is not enough – part 1</a> articles last July I started to write a follow up showing another use of the raw data format. I&#8217;ve just found the source code and notes I&#8217;d put together so I figured I&#8217;d throw it up in it&#8217;s rough form (the youtube video&#8217;s been linking to an unpublished article for about a year :S )</p>
<h3>The result</h3>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/50SKR45ET44?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>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&#8217;ve used 0 to represent the highest points and 255 the lowest.<br />
<span id="more-496"></span><br />
I&#8217;ve thrown all the code into the HelloWorld layer and this example uses 1 pixel in the depth map to represent 1 pixel in the hill image, if you don&#8217;t need this level of accuracy you could make your depth map smaller and adjust your calculation for the offset. The depth map itself was created in photoshop using the gradient tool.</p>
<h3>The resources</h3>
<p>The resource link contains the Photoshop document and a copy of the depth map and the &#8216;hill&#8217; images. </p>
<div id="attachment_512" class="wp-caption aligncenter" style="width: 810px"><a href="http://abitofcode.com/wp-content/uploads/2011/07/2011_07_17_1_map_and_depth.png"><img src="http://abitofcode.com/wp-content/uploads/2011/07/2011_07_17_1_map_and_depth.png" alt="" title="2011_07_17_1_map_and_depth" width="800" height="299" class="size-full wp-image-512" /></a><p class="wp-caption-text">Fig 1.The visible map and the depth data</p></div>
<p>The depth map image above contains &#8216;ff&#8217; values as it approaches the end of the file as the bottom right of the depth map is white (see above). We can check this in the terminal.</p>
<div class="terminal">
>hexdump depth.raw | tail<br />
0075250 dc db dc dd dd de dd dd df df df df e0 e0 e1 e2<br />
0075260 e2 e2 e3 e2 e3 e4 e5 e5 e4 e5 e6 e6 e7 e7 e6 e8<br />
0075270 e8 e8 e9 ea e9 ea eb ea eb eb ec ec ed ed ed ed<br />
0075280 ee ef ee ef ef f0 f1 f1 f0 f1 f2 f1 f2 f2 f3 f3<br />
0075290 f4 f4 f3 f4 f4 f5 f6 f5 f6 f6 f7 f7 f7 f8 f7 f8<br />
00752a0 f9 f9 f9 f9 fa fa fa fa fb fb fb fc fb fc fc fc<br />
00752b0 fc fe fe fd fd fe ff fd fe ff ff ff ff ff ff ff<br />
00752c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff<br />
*<br />
0075300</p>
<p>>printf &#8220;%d\n&#8221; 0&#215;0075300<br />
480000
</p></div>
<p>The work is done here;</p>

<div class="wp_codebox"><table><tr id="p49648"><td class="code" id="p496code48"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>getHeightAtPoint<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>pt
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// set the value to -1, a default no data at point</span>
  <span style="color: #a61390;">int</span> retValue <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// if the image lookup data is present and the value is within the bounds of the image</span>
  <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self.depthData <span style="color: #002200;">&amp;&amp;</span> CGRectContainsPoint<span style="color: #002200;">&#40;</span>CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, IMAGE_WIDTH, IMAGE_HEIGHT<span style="color: #002200;">&#41;</span>, pt<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> 
  <span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// The raw data assumes a top left origin</span>
    pt.y <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>IMAGE_HEIGHT <span style="color: #002200;">-</span> pt.y<span style="color: #002200;">&#41;</span> <span style="color: #002200;">-</span> <span style="color: #2400d9;">1</span>;       
&nbsp;
    <span style="color: #11740a; font-style: italic;">// calculate an offset</span>
    <span style="color: #a61390;">int</span> offset <span style="color: #002200;">=</span> pt.y <span style="color: #002200;">*</span> IMAGE_WIDTH <span style="color: #002200;">+</span> pt.x;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// get the data at the offset</span>
    <span style="color: #a61390;">NSRange</span> range <span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span>offset,<a href="http://www.opengroup.org/onlinepubs/009695399/functions/sizeof.html"><span style="color: #a61390;">sizeof</span></a><span style="color: #002200;">&#40;</span>Byte<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#125;</span>;
    <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> <span style="color: #002200;">*</span>pixelValue <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>depthData subdataWithRange<span style="color: #002200;">:</span>range<span style="color: #002200;">&#93;</span>;  
&nbsp;
    retValue <span style="color: #002200;">=</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>pixelValue bytes<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// We want 255 to be the lowest value</span>
    retValue <span style="color: #002200;">=</span> <span style="color: #2400d9;">255</span> <span style="color: #002200;">-</span> retValue;
  <span style="color: #002200;">&#125;</span>
  <span style="color: #a61390;">return</span> retValue;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p><a href="http://abitofcode.com/wp-content/plugins/download-monitor/download.php?id=12">DepthMap source</a><br />
<a href="http://abitofcode.com/wp-content/plugins/download-monitor/download.php?id=13">DepthMap resources</a></p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/cZzeTeZ7Cfc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2012/06/building-a-depth-map-for-cocos2d-in-photoshop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2012/06/building-a-depth-map-for-cocos2d-in-photoshop/</feedburner:origLink></item>
		<item>
		<title>Spritesheets the Movie</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/s8k_T_7a-E8/</link>
		<comments>http://abitofcode.com/2012/06/spritesheets-the-movie/#comments</comments>
		<pubDate>Fri, 22 Jun 2012 19:20:52 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=990</guid>
		<description><![CDATA[A great explanation in animated form of the reasoning behind using a Spritesheet from the creator of TexturePacker Andreas Loew @codeAndWeb. SpriteSheets &#8211; TheMovie &#8211; Part 1 by Code&#8217;n'Web Consider this the Episode IV of Spritesheet movies]]></description>
				<content:encoded><![CDATA[<p>A great explanation in animated form of the reasoning behind using a Spritesheet from the creator of <a href="http://www.codeandweb.com">TexturePacker</a> Andreas Loew <a href="http://twitter.com/@codeAndWeb">@codeAndWeb</a>. </p>
<p><iframe src="http://player.vimeo.com/video/44440528" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://www.codeandweb.com/what-is-a-sprite-sheet">SpriteSheets &#8211; TheMovie &#8211; Part 1</a> by <a href="http://www.codeandweb.com">Code&#8217;n'Web</a></p>
<p>Consider this the Episode IV of Spritesheet movies <img src='http://abitofcode.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/s8k_T_7a-E8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2012/06/spritesheets-the-movie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2012/06/spritesheets-the-movie/</feedburner:origLink></item>
		<item>
		<title>Cocos2d – Getting started</title>
		<link>http://feedproxy.google.com/~r/abitofcode/JoZG/~3/KwayZjhkvB8/</link>
		<comments>http://abitofcode.com/2012/05/cocos2d-getting-started/#comments</comments>
		<pubDate>Wed, 09 May 2012 16:22:23 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[app]]></category>
		<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[cocos2d]]></category>
		<category><![CDATA[cocos2dx]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[podcast]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[screencast]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://abitofcode.com/?p=842</guid>
		<description><![CDATA[The following is a list of links and resources that should make finding your way around Cocos2d a little easier. Beware of older code examples and tutorials when looking for help, a lot changed between Cocos2d v0.82 and v1.0 including &#8230; <a href="http://abitofcode.com/2012/05/cocos2d-getting-started/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://abitofcode.com/wp-content/uploads/2012/05/cocos2dlogo.jpg"><img class="alignright size-full wp-image-927" title="cocos2dlogo" src="http://abitofcode.com/wp-content/uploads/2012/05/cocos2dlogo.jpg" alt="" width="170" height="250" /></a><br />
The following is a list of links and resources that should make finding your way around Cocos2d a little easier.</p>
<p>Beware of older code examples and tutorials when looking for help, a lot changed between Cocos2d v0.82 and v1.0 including the names of a lot of the framework methods.</p>
<p>The simplest way to find which version a project is using is to open up the cocos2d.m file and look for the version string</p>

<div class="wp_codebox"><table><tr id="p84250"><td class="code" id="p842code50"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>version <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;cocos2d v1.1.0-beta2b&quot;</span>;</pre></td></tr></table></div>

<p>IMHO the best way to get into Cocos2d is to build something with it. Don&#8217;t look at the resources below as something you have to finish before you begin or you&#8217;ll never get started <img src='http://abitofcode.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>In no particular order;<br />
<span id="more-842"></span></p>
<h2>1. Books</h2>
<p>There are some great Cocos2d books out there now, the following are personal favorites in no particular order;</p>
<p><strong><a href="http://www.amazon.co.uk/gp/product/0321735625/ref=as_li_qf_sp_asin_il?ie=UTF8&amp;tag=abitofcodecom-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=0321735625">Learning Cocos2D: A Hands-on Guide to Building IOSGames with Cocos2D, Box2D, and Chipmunk (Addison-Wesley Learning Series)</a></strong><br />
By Rod Strougo and Ray Wenderlich<br />
<a href="http://www.amazon.co.uk/gp/product/0321735625/ref=as_li_qf_sp_asin_il?ie=UTF8&amp;tag=abitofcodecom-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=0321735625"><img style="float: right;" src="http://ws.assoc-amazon.co.uk/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=0321735625&amp;MarketPlace=GB&amp;ID=AsinImage&amp;WS=1&amp;tag=abitofcodecom-21&amp;ServiceVersion=20070822" alt="" border="0" /></a><br />
Comprehensive coverage of the Cocos2d framework, also covers the Box2d and Chipmunk physics engines and Game Center integration. The book walks the user through the development of a game &#8216;Space Viking&#8217; that contains mini games each using a different aspect of the framework. There&#8217;s also a nice Chapter on performance optimizations towards the end that should save you a bit of time trawling through the forums if your frame rate starts dropping.</p>
<p><strong><a href="http://www.cartoonsmart.com/ibook.php5">CartoonSmart &#8211; iBook on How to Get Started with XCode And Cocos2D Game Development</a></strong></p>
<p>Still under development, the first 4 chapters are free (5 if you hurry and sign up to the cartoonSmart newsletter) and provide a great introduction to programming Cocos2d. Geared towards the beginner the chapters are clearly written in a friendly style and introduce new information as it is required rather than dump it all on you at the beginning. You can see a movie of the iBooks version in action over at the website and the book is also available as a pdf.</p>
<p><strong><a href="http://www.amazon.co.uk/gp/product/1849514003/ref=as_li_qf_sp_asin_il?ie=UTF8&amp;tag=abitofcodecom-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=1849514003">Cocos2d for iPhone 1 Game Development Cookbook</a></strong><br />
By Nathan Burba<br />
<a href="http://www.amazon.co.uk/gp/product/1849514003/ref=as_li_qf_sp_asin_il?ie=UTF8&amp;tag=abitofcodecom-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=1849514003"><img style="float: right;" src="http://ws.assoc-amazon.co.uk/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=1849514003&amp;MarketPlace=GB&amp;ID=AsinImage&amp;WS=1&amp;tag=abitofcodecom-21&amp;ServiceVersion=20070822" alt="" border="0" /></a><br />
I&#8217;m a big fan of the Cookbook approach, I take a similar approach when experimenting. Great for the Inquisitive/Intermediate programmer and covers a wide variety of techniques. For further detail check out Nathans site <a href="http://cocos2dcookbook.com/">http://cocos2dcookbook.com/</a> which has videos detailing the techniques covered in the book.</p>
<p><strong><a href="http://www.amazon.co.uk/gp/product/B006CO7ZQ0/ref=as_li_qf_sp_asin_il?ie=UTF8&amp;tag=abitofcodecom-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=B006CO7ZQ0">Learn cocos2d Game Development with iOS 5 (Learn Apress) [Kindle Edition]</a></strong><br />
By Steffen Itterheim<br />
<a href="http://www.amazon.co.uk/gp/product/B006CO7ZQ0/ref=as_li_qf_sp_asin_il?ie=UTF8&amp;tag=abitofcodecom-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=B006CO7ZQ0"><img style="float: right;" src="http://ws.assoc-amazon.co.uk/widgets/q?_encoding=UTF8&amp;Format=_SL110_&amp;ASIN=B006CO7ZQ0&amp;MarketPlace=GB&amp;ID=AsinImage&amp;WS=1&amp;tag=abitofcodecom-21&amp;ServiceVersion=20070822" alt="" border="0" /></a><br />
Quick disclaimer &#8211; I don&#8217;t have the latest version (this is a Kindle version) I have the version <a href="http://www.amazon.co.uk/gp/product/1430233036">here</a> which is now a little out of date. This was the first book to fill the Cocos2d book void and takes you through the development of several increasingly complex games. It&#8217;s aimed at the beginner games programmer but there are plenty of tips and suggestions that should benefit the majority of cocos2d developers.</p>
<h2>2. Download Cocos2d and have a look at the Tests</h2>
<p>There are plenty of tutorials out there describing how to download Cocos2d and install the templates into XCode, not all of them make it clear that the downloaded folder also contains a tests folder with code demonstrating each of Cocos2d&#8217;s main features. The code isn&#8217;t the easiest code to read, these are tests rather than tutorials but they should give you an idea of what Cocos2D can do. Just open cocos2d-ios.xcodeproj in Xcode and select the test to build.</p>
<p>Some of these tests can be seen running in this youtube offering from 2009</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='620' height='379' src='http://www.youtube.com/embed/JjDTpWFl2kA?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<h2>3. Cocos2d API reference</h2>
<p>Until recently I Integrated the cocos2d API reference into XCode using the approach <a href="http://www.cocos2d-iphone.org/archives/358">detailed here</a>. As soon as you get past 3 Doc sets in Xcode however, life becomes exponentially slower. I was really happy to find <a href="http://itunes.apple.com/gb/app/dash-docs-snippets/id458034879?mt=12">Dash</a> recently which not only gives me a fast search into the cocos2d API but also makes snippets available via abbreviations and allows placeholders. The developer of <a href="http://itunes.apple.com/gb/app/dash-docs-snippets/id458034879?mt=12">Dash</a> has indicated that there will be a browse feature in the coming update.<br />
Install via the Mac App store (currently free) then select Cocos2d in Preferences &gt; Docsets.</p>
<div id="attachment_852" class="wp-caption aligncenter" style="width: 810px"><a href="http://itunes.apple.com/gb/app/dash-docs-snippets/id458034879?mt=12"><img class="size-full wp-image-852" title="2012-05-08_Dash" src="http://abitofcode.com/wp-content/uploads/2012/05/2012-05-08_Dash.jpg" alt="" width="800" height="483" /></a><p class="wp-caption-text">Dash &#8211; Quick just like Xcode isn&#8217;t</p></div>
<h2>4. Screencasts</h2>
<p>If video is your preferred means of learning the following may help you avoid trawling through YouTube.</p>
<p><strong>Bob Ueland&#8217;s Cocos2d tutorials</strong><br />
<a href="http://bobueland.com/cocos2d/tutorials/">http://bobueland.com/cocos2d/tutorials/</a></p>
<p><a href="https://twitter.com/uelandbob" target="_blank">Bob</a> has a great set of free screencasts covering a broad spectrum of the Cocos2d framework. If touches, animations and Node spaces are causing you issues then this would be the first place I would suggest looking. The screencasts are short but focused and Bob&#8217;s style is naturally clear and to the point.<br />
For anyone wanting a project walkthrough in the same style, <a href="https://twitter.com/uelandbob" target="_blank">Bob</a> now has a <a href="http://bobueland.com/cocos2d/cocos2d-course/">paid course</a> that takes you through the development of a shoot-em-up game complete with end of level Boss fight named &#8216;<a href="http://bobueland.com/cocos2d/cocos2d-course/">Galaxy Fighter</a>&#8216;. This is a great introduction to writing/structuring your own game.</p>
<p><strong>Cocos2d introduction and code walkthrough</strong><br />
Two great videos from the guys over at <a href="https://twitter.com/curiodept">The Curio Dept.</a> <br />
The first video is a 30 minute walkthrough that gives an overview of Cocos2d, if you&#8217;re new to Cocos2d this birds eye view is a great place to start.<br />
<a href="https://www.youtube.com/watch?v=JObVn3Fu9l8#!">Introduction to Cocos2d &#8211; 30 mins</a><br />
The other video takes a walkthrough approach building up a &#8216;Fruit Assassin&#8217; game, there&#8217;s a link to the slides and source code in the notes of the link above.<br />
<a href="https://www.youtube.com/watch?v=T1-yARGKhXU">Code walkthrough &#8211; 90 mins</a><br />
<br/></p>
<p><strong>LearnCocosTV by Steffen Itterheim </strong><br />
<a href="http://itunes.apple.com/gb/podcast/learncocostv/id510149983">iTunes</a> <a href="http://www.youtube.com/user/LearnCocos2D">YouTube</a><br />
Covers Cocos2d and Steffens Project <a href="http://www.kobold2d.com/">Kobold2d</a> (built upon cocos2d). The first special covered <a href="http://www.youtube.com/watch?feature=player_embedded&amp;v=kYIMofmWgX8">Enabling ARC in a Cocos2D project</a>.</p>
<p><strong>Learning Cocos2d Development by AzamSharp</strong><br />
<a href="http://www.youtube.com/playlist?list=PL3D5A9CF48EDF6ED3">YouTube</a><br />
A collection of short video tutorials introducing you to various aspects of Cocos2D.</p>
<p><strong>Paulson Apps</strong><br />
<a href="http://vimeo.com/user3292522">Vimeo</a> <a href="http://www.youtube.com/user/paulsondev?feature=watch">YouTube</a><br />
Interesting set of videos following the development of a game in cocos2d with some tutorials along the way.</p>
<p><strong>iPad and iPhone Application Development (HD) &#8211; by Paul Hegarty</strong><br />
<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=473757255">iTunes</a><br />
Though not a Cocos2D resource this is the daddy of iOS screenCasts. Great coverage of iPhone development with ObjectiveC and UIKit.</p>
<p><strong>What is a sprite sheet? &#8211; The Movie</strong><br />
<a href="http://www.codeandweb.com/what-is-a-sprite-sheet">SpriteSheets the movie</a><br />
At 3 minutes long this is a great introduction to Spritesheets and why we use them by @codeandweb. <a class="twitter-follow-button" href="https://twitter.com/codeandweb" data-show-count="false" data-lang="en">@codeandweb</a></p>
<h2>5. Websites and Blogs</h2>
<p><strong>Cocos2D for iPhone</strong><br />
<a href="http://www.cocos2d-iphone.org/" target="_blank">http://www.cocos2d-iphone.org/</a><br />
The home of Cocos2D for iPhone, the place to download it, show your final results, take part in the forum and find documentation.</p>
<p>The <a href="http://www.cocos2d-iphone.org/wiki/doku.php/" target="_blank">documentation</a> is in the form of a <a href="http://www.cocos2d-iphone.org/wiki/doku.php/" target="_blank">wiki</a> and contains a lot of useful resources including;</p>
<p>* Best practices<br />
* Programming guide<br />
* Migration guide<br />
* Tips/Tricks<br />
* Sample games<br />
* The logos<br />
* Release notes<br />
* Performance tests<br />
* Templates<br />
* CocosDenshion Audio library cookbook</p>
<p><strong>RayWenderlich.com</strong><br />
<a href="http://www.raywenderlich.com" target="_blank">http://www.raywenderlich.com</a><br />
A great site for well researched and written Cocos2d and iOS tutorials. It&#8217;s grown from <a href="https://twitter.com/rwenderlich" target="_blank">Ray&#8217;s</a> one man blog to a full team of well seasoned iOS developers pushing tutorials out at an alarming rate. I tend to look here before searching the apple documentation <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  A quick look through the <a href="http://www.raywenderlich.com/tutorials" target="_blank">tutorials</a> link should provide a selection of Cocos2d tutorials for all abilities.<br />
The site has it&#8217;s own forum for questions/discussions around the articles and there is a regular vote to determine the subject of the next article.</p>
<p><strong>Learn Cocos2d by Steffen Itterheim</strong><br />
<a href="http://www.learn-cocos2d.com" target="_blank">http://www.learn-cocos2d.com</a><br />
Some really useful stuff on this site by Steffen, have a look through the <a href="http://www.learn-cocos2d.com/blog/" target="_blank">blog</a> for some great articles covering both Cocos2D and game development. Steffen is pretty thorough so whether the subject is piracy, enabling ARC or CCArray performance tests you should get something out of it.</p>
<p><strong>Abitofcode</strong><br />
<a href="http://www.abitofcode.com" target="_blank">http://www.abitofcode.com</a><br />
Doesn&#8217;t post as regularly as most sites, but tries to cover the odd technique that may not get featured elsewhere, the cocos2d specific articles can be found <a href="http://abitofcode.com/category/cocos2d/" target="_blank">here</a>.</p>
<h2>6. Podcast</h2>
<p>There&#8217;s a great Cocos2d podcast By <a href="https://twitter.com/azamsharp" target="_blank">Mohammad Azam </a> &amp; <a href="https://twitter.com/gaminghorror" target="_blank">Steffen Itterheim</a> that focuses on the framework and the people in and around the Cocos2d community. Recent podcasts can be accessed <a href="http://itunes.apple.com/us/podcast//id433503418">via iTunes</a>, for the full back catalogue check out their <a href="http://cocos2dpodcast.wordpress.com/">blog here</a>.</p>
<h2>7. Twitter</h2>
<p>Another way to keep up to date with what&#8217;s going on is to follow people who tweet about Cocos2d and iOS development on a regular basis. <a href="http://twitter.com">Twitter</a> is a great tool for keeping up to date, letting people know about your app, finding beta testers and finding solutions to dev problems.</p>
<p><a class="twitter-follow-button" href="https://twitter.com/cocos2d" data-show-count="false" data-lang="en">Follow @cocos2d</a><a class="twitter-follow-button" href="https://twitter.com/rwenderlich" data-show-count="false" data-lang="en">Follow @rwenderlich</a><a class="twitter-follow-button" href="https://twitter.com/abitofcode" data-show-count="false" data-lang="en">Follow @abitofcode</a><a class="twitter-follow-button" href="https://twitter.com/iuridium" data-show-count="false" data-lang="en">Follow @iuridium</a><a class="twitter-follow-button" href="https://twitter.com/uelandbob" data-show-count="false" data-lang="en">Follow @uelandbob</a><a class="twitter-follow-button" href="https://twitter.com/gaminghorror" data-show-count="false" data-lang="en">Follow @gaminghorror</a><a class="twitter-follow-button" href="https://twitter.com/cocos2dx" data-show-count="false" data-lang="en">Follow @cocos2dx</a></p>
<p>If you want to follow/build up a following of Cocos2D twitter users it&#8217;s also worth checking the <a href="http://www.cocos2d-iphone.org/forum/topic/13496">Twitter thread</a> on the Cocos2D forum, there&#8217;s also a <a href="http://www.cocos2d-iphone.org/forum/topic/18560">Google+ thread here</a>. The tags #cocos2d and #cchandshake are occasionally used to highlight Cocos2d specific content but a search for &#8216;cocos2d&#8217; usually brings up some interesting results.</p>
<h2>8. Sign up to a good newsletter</h2>
<p>If you&#8217;re new to iOS development it can help to have other people do the research for you <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The following newsletters cover iOS development in general.</p>
<p>* <a href="http://iosdevweekly.com/">IOS Dev Weekly By Dave Verwer</a><br />
* <a href="http://www.raywenderlich.com/">Ray&#8217;s monthly newsletter by Ray Wenderlich</a><br />
* <a href="http://ymlp.com/signup.php?id=gebusqsgmgj">Learn-cocos2d by Steffen Itterheim</a></p>
<h2>9. Paid Resources</h2>
<p>Some people prefer to purchase their materials rather than hunt around the web, here&#8217;s a collection of the better known resources out there for sale. Please consider any purchases carefully.</p>
<p>* <a href="http://www.sapusmedia.com/products/">Sapus tongue</a> by Ricardo Quesada (***No longer available***)<br />
* <a href="http://bobueland.com/cocos2d/cocos2d-course/">Galaxy Fighter</a> by Bob Ueland<br />
* <a href="http://www.raywenderlich.com/store/space-game-starter-kit">Space Game starter kit</a> from Ray Wenderlich<br />
* <a href="http://iphonegamekit.com/">iPhoneGame Kit</a> by Nat Weiss<br />
* <a href="http://www.iuridium.com/?page_id=2">iUridium</a><br />
* <a href="http://www.learn-cocos2d.com/store/line-drawing-game-starterkit/">Line-Drawing game</a> by Steffen Itterheim</p>
<h2>10. Get familiar with Git</h2>
<p>Git is a distributed revision control and source code management (SCM) system and has made sharing code between developers much simpler. Grab an account on <a href="https://github.com/" target="_blank">GitHub</a> (free for public use) and start following some projects.</p>
<p>For a <a href="https://github.com/hiepnd/CCBlade" target="_blank">Fruit Ninja style blade effect</a> there&#8217;s <a href="https://github.com/hiepnd/CCBlade" target="_blank">this repo</a>.</p>
<p>Another one to watch is the <strong>Cocos2d Extensions repo</strong> maintained by <a href="https://twitter.com/#!/parkourDev" target="_blank">Stepan Generalov</a> which adds a number of features to the Cocos2D framework including the following;</p>
<p>* <strong>CCMenuAdvanced</strong> &#8211; CCMenu subclass with additional features: relativeAnchor, more align options, priority property, scrolling with swipe/trackpad/mousewheel<br />
* <strong>CCMenuItemSpriteIndependent</strong> &#8211; CCMenuItemSprite Subclass, that doesnt add normal/selected/disabled images (sprites) as children. It retains them and delegates rect &amp; convertToNodeSpace: methods to normalImage_. So it&#8217;s possible to use CCSpriteBatchNode &amp; add position sprites of menuItem anyway you want.<br />
* <strong>CCVideoPlayer</strong> &#8211; Simple Video Player for Cocos2D apps.<br />
* <strong>CCBigImage</strong> &#8211; Dynamic Tiled Node for holding Large Images.<br />
* <strong>CCSlider</strong> &#8211; Little Slider Control to allow the user to set the music/sfx/etc level in the range of 0.0f to 1.0f.<br />
* <strong>CCSendMessages</strong> &#8211; CCActionInstant subclass, that is more flexible than other CCActions that run functions. Can be used in many cases as blocks replacement.<br />
* <strong>CCScrollLayer</strong> &#8211; CCLayer subclass that lets you pass-in an array of layers and it will then create a smooth scroller. Complete with the &#8220;snapping&#8221; effect.<br />
* <strong>FilesDownloader</strong> &#8211; Downloader for a group of files with shared source path.<br />
* <strong>TMXGenerator</strong> &#8211; Class that generates a single TMX map with multiple layers.<br />
* <strong>CCLayerPanZoom</strong> &#8211; CCLayer subclass that can be scrolled and zoomed with one or two fingers (complete with rubber effect, two modes &amp; ability to click through delegate).</p>
<p>One way to find projects of interest is to keep an eye out in the <a href="http://www.cocos2d-iphone.org/forum" target="_blank">Cocos2d</a> forum. Doing a search for <strong>github</strong> in the forum can produce some interesting results -&gt; <a href="http://www.cocos2d-iphone.org/forum/search.php?q=github" target="_blank">Search for Github in Cocos2D forum</a></p>
<p>(Just found this one <a href="https://github.com/sqlboy/tiled-games/tree/master/src" target="_blank">CCTMXTiledMap A* pathfinding class</a> -&gt; while writing this <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<p>If you need a little help getting to grips with Git, O&#8217;Reilly have produced a video course &#8216;Mastering Git&#8217; by Matthew McCullough and Tim Berglund that can be purchased <a href="http://shop.oreilly.com/product/0636920017462.do?green=22095378280&amp;intcmp=af-mybuy-0636920017462.IP" target="_blank">here</a>.</p>
<h2>11. The Cocos2D forum</h2>
<p><a href="http://www.cocos2d-iphone.org/forum/" target="_blank">http://www.cocos2d-iphone.org/forum/</a></p>
<p>The MotherShip and a great resource for all things Cocos2D but please take time to read the <a href="http://www.cocos2d-iphone.org/forum/topic/3">READ BEFORE POSTING</a> sticky post before posting your first post, it&#8217;ll also explain how to set your avatar. If you don&#8217;t have an external website, consider setting the link in your profile to your twitter address instead.<br />
There are lots of experienced and friendly Cocos2d developers willing to help out but they like to see that you&#8217;ve had a go yourself and you&#8217;ve posted to the right place.</p>
<p>We&#8217;re not keen on the phrase &#8220;<a href="http://www.cocos2d-iphone.org/forum/topic/31922" target="_blank">RockStar programmer</a>&#8221; <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Google indexes the forum on a regular basis so if the forum search isn&#8217;t returning the results you want, try searching directly in Google, just add cocos2d as one of your search words.</p>
<h2>12. Don&#8217;t reinvent the wheel</h2>
<p>If you came to iOS from ActionScript like me you&#8217;ll probably start of by building a bunch of helper methods and Classes, it&#8217;s worth taking a little time to look through the Cocos2D framework and some of the other frameworks first though. You can jump to a methods definition in XCode by holding Command and clicking the method name once a link shows below it.</p>
<p>Here&#8217;s some of the more useful bits;</p>
<p><strong>ccMacros.h</strong> &#8211; Cocos2d<br />
- COCOS2D_DEBUG<br />
- CC_SWAP &#8211; simple macro that swaps 2 variables<br />
- CCRANDOM_MINUS1_1() returns a random float between -1 and 1<br />
- CCRANDOM_0_1() returns a random float between 0 and 1<br />
- CC_DEGREES_TO_RADIANS() converts degrees to radians<br />
- CC_RADIANS_TO_DEGREES() converts radians to degrees<br />
- CC_ENABLE_DEFAULT_GL_STATES()<br />
- CC_DISABLE_DEFAULT_GL_STATES()<br />
- CC_DIRECTOR_INIT() Depth, Pixelformat, GLView bounds&#8230;<br />
- CC_CONTENT_SCALE_FACTOR() Mac = 1, iPhone Retina = 2 otherwise = 1<br />
- CC_RECT_PIXELS_TO_POINTS(pixels) Converts a rect in pixels to points<br />
- CC_RECT_POINTS_TO_PIXELS(points) Converts a rect in points to pixels</p>
<p><strong>CGPointExtension.h &amp; CGPointExtension.m </strong> &#8211; Cocos2D Point extensions<br />
These contains a lot of useful shortcuts, well worth a quick read through they include;<br />
- <strong>ccp</strong> &#8211; CGPointMake shortcut<br />
- <strong>ccpNeg</strong> &#8211; Returns opposite of point<br />
- <strong>ccpAdd</strong> &#8211; Calculates sum of two points<br />
- <strong>ccpSub</strong> &#8211; Calculates difference of two points<br />
- <strong>ccpMult</strong> &#8211; Returns point multiplied by given factor<br />
- <strong>ccpMidpoint</strong> &#8211; Calculates midpoint between two points<br />
- <strong>ccpDot</strong> &#8211; Calculates dot product of two points<br />
- <strong>ccpCross</strong> &#8211; Calculates cross product of two points<br />
- <strong>ccpPerp</strong> &#8211; Calculates perpendicular of v, rotated 90 degrees counter-clockwise<br />
- <strong>ccpRPerp</strong> &#8211; Calculates perpendicular of v, rotated 90 degrees clockwise<br />
- <strong>ccpProject</strong> &#8211; Calculates the projection of v1 over v2<br />
- <strong>ccpRotate</strong> &#8211; Rotates two points<br />
- <strong>ccpUnrotate</strong> &#8211; Unrotates two points<br />
- <strong>ccpLengthSQ</strong> &#8211; Calculates the square length of a CGPoint (not calling sqrt() )<br />
- <strong>ccpLength</strong> &#8211; Calculates distance between point an origin<br />
- <strong>ccpDistance</strong> &#8211; Calculates the distance between two points<br />
- <strong>ccpNormalize</strong> &#8211; Returns point multiplied to a length of 1<br />
- <strong>ccpForAngle</strong> &#8211; Converts radians to a normalized vector<br />
- <strong>ccpToAngle</strong> &#8211; Converts a vector to radians<br />
- <strong>clampf</strong> &#8211; Clamp a value between from and to<br />
- <strong>ccpClamp</strong> &#8211; Clamp a point between from and to<br />
- <strong>ccpFromSize</strong> &#8211; Quickly convert CGSize to a CGPoint<br />
- <strong>ccpCompOp</strong> &#8211; Run a math operation function on each point component<br />
- <strong>ccpLerp</strong> &#8211; Linear Interpolation between two points a and b<br />
- <strong>ccpFuzzyEqual</strong> &#8211; returns if points have fuzzy equality which means equal with some degree of variance<br />
- <strong>ccpCompMulti</strong> &#8211; Multiplies a nd b components, a.x*b.x, a.y*b.y<br />
- <strong>ccpAngleSigned</strong> &#8211; returns the signed angle in radians between two vector directions<br />
- <strong>ccpAngle</strong> &#8211; returns the angle in radians between two vector directions<br />
- <strong>ccpRotateByAngle</strong> &#8211; Rotates a point counter clockwise by the angle around a pivot<br />
- <strong>ccpLineIntersect</strong> &#8211; A general line-line intersection test<br />
- <strong>ccpSegmentIntersect</strong> &#8211; returns YES if Segment A-B intersects with segment C-D<br />
- <strong>ccpIntersectPoint</strong> &#8211; returns the intersection point of line A-B, C-D</p>
<p>If the above functions make no sense at all visit <a href="http://www.wildbunny.co.uk/blog/vector-maths-a-primer-for-games-programmers/" target="_blank">WildBunny.co.uk</a> for the best Vector maths primer on the web by <a href="http://twitter.com/paul_m_firth" target="_blank">@paul_m_firth</a></p>
<p><strong>CCDrawingPrimitives.h</strong> &#8211; Cocos2D Drawing OpenGL ES primitives<br />
- ccDrawPoint<br />
- ccDrawLine<br />
- ccDrawPoly<br />
- ccDrawCircle<br />
- ccDrawQuadBezier<br />
- ccDrawCubicBezier</p>
<p><strong>UIGeometry.h </strong><br />
- NSStringFromCGPoint(CGPoint point);<br />
- NSStringFromCGSize(CGSize size);<br />
- NSStringFromCGRect(CGRect rect);</p>
<p><strong>CGGeometry.h</strong> (Core Graphics framework)<br />
- CGRectGetHeight(CGrect rect)<br />
- CGRectGetMinX<br />
- CGRectGetMidX<br />
- CGRectGetMaxX<br />
- CGRectContainsPoint<br />
- CGRectContainsRect<br />
- CGRectIntersectsRect<br />
- CGPointMake<br />
- CGSizeMake<br />
- CGRectMake</p>
<p>Before you invent any of your own basic structs and type check out ccTypes.h which contains things like vertex structures, texture coords and colors (including some predefined colors ccRed, ccBlue, ccGreen etc).</p>
<h2>and finally&#8230;</h2>
<p>Fortunately &#8216;cocos2d&#8217; is fairly unique and narrows the search down somewhat in google. The following links contains some great resources including tutorials and open source games to tinker with, well worth a bookmark.</p>
<p>* <a href="http://www.iuridium.com/?p=436" target="_blank">List of Open Source Cocos2d Projects, Extensions and Code Snippets</a> by <a href="https://twitter.com/#!/iuridium" target="_blank">@iUridium</a></p>
<p>* <a href="http://www.supersuraccoon-cocos2d.com/2012/02/11/sticky-ios-cocos2d-develop-recommended-blog-list-keep-updating/" target="_blank">ios-cocos2d develop Recommended Blog List</a> by <a href="https://twitter.com/#!/supersuraccoon" target="_blank">@SuperSuRaccoon</a></p>
<p>* <a href="http://maniacdev.com/cocos2d-tutorial-and-example-page/" target="_blank">Cocos2D Tutorial And Example Page</a> by <a href="https://twitter.com/#!/maniacdev" target="_blank">@maniacdev</a></p>
<p>Enough reading! Go and make something shiny <img src='http://abitofcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/abitofcode/JoZG/~4/KwayZjhkvB8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://abitofcode.com/2012/05/cocos2d-getting-started/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://abitofcode.com/2012/05/cocos2d-getting-started/</feedburner:origLink></item>
	</channel>
</rss>
