<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Tiny Tim Games</title>
	<atom:link href="http://www.tinytimgames.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tinytimgames.com</link>
	<description>Just For Fun</description>
	<lastBuildDate>Sat, 15 Jun 2013 02:23:47 +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>
		<item>
		<title>Full-Time Indie</title>
		<link>http://www.tinytimgames.com/2013/06/14/full-time-indie/</link>
		<comments>http://www.tinytimgames.com/2013/06/14/full-time-indie/#comments</comments>
		<pubDate>Sat, 15 Jun 2013 02:23:47 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Indie]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=934</guid>
		<description><![CDATA[Two weeks from today will be my last day as a full-time employee. There. That feels good to get out. But it&#8217;s true. Starting in July, I&#8217;m on my own again, without the safety net of a guaranteed paycheck every week. Of course, paychecks are never guaranteed, especially in the technology business. But those of [...]]]></description>
				<content:encoded><![CDATA[<p>Two weeks from today will be my last day as a full-time employee.</p>
<p>There. That feels good to get out. But it&#8217;s true. Starting in July, I&#8217;m on my own again, without the safety net of a guaranteed paycheck every week. Of course, paychecks are never guaranteed, especially in the technology business. But those of us with full-time jobs like toÂ <em>think</em> there&#8217;s more stability there than there actually is.</p>
<p>Anyways, some of you who follow me may be a bit confused by this turn of events. So allow me to explain&#8230;</p>
<p><span id="more-934"></span></p>
<p>A few weeks ago, I made this bold claim on Twitter:</p>
<blockquote class="twitter-tweet" width="500"><p>So yeah, I think I&#39;m done trying to be an independent game developer.</p>
<p>&mdash; Jerrod Putman (@jerrodputman) <a href="https://twitter.com/jerrodputman/statuses/328636037935005696">April 28, 2013</a></p></blockquote>
<p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>After literally years of trying to work a full-time job and do part-time independent game development, I had become so frustrated that I finally just snapped and decided to stop trying. What followed was a long period of thought, soul searching, and prayer.</p>
<p>For two years, starting in 2009, I tried to make it as an indie game developer. In that time, we did manage to release two iOS games that I&#8217;m proud of. They never made enough for us to live off of, though, so when my wife and I found out mid-2010 that we were going to have a baby, I knew I needed to do something else. And thus I returned to full-time employment.</p>
<p>I&#8217;ve been at this job for over two years now, and I actually really enjoy the work. I don&#8217;t like the commute that much, but the work itself is actually pretty rewarding, as I get to develop iOS apps that specifically require the use of UIKit and all of Apple&#8217;s libraries.</p>
<p>With that said, this isn&#8217;t why I became a programmer. I went to Full Sail because I wanted to get into games. But at the same time, I&#8217;ve worked in the AAA games industry, and I never ever want to go back into that sort of life: the long hours, never getting to see my family, the poor management. The only way I would ever tolerate any of that is if it were my own game that I had complete control over.</p>
<p>And so, I&#8217;m going to give it another shot. And I&#8217;m going to give it the best shot I can. I&#8217;ve already got office space rented so I have a dedicated space to work (as opposed to a bedroom). In fact, here&#8217;s a shot of the office:</p>
<p style="text-align: center;">Â <a href="http://www.tinytimgames.com/wp-content/uploads/2013/06/Photo-Jun-05-8-46-05-PM.jpg"><img class="aligncenter  wp-image-935" alt="The New Office" src="http://www.tinytimgames.com/wp-content/uploads/2013/06/Photo-Jun-05-8-46-05-PM-1024x397.jpg" width="574" height="222" /></a></p>
<p>I&#8217;ve also decided that I&#8217;m done with iOS-only games. We already use Unity for everything we do, so we might as well go multiplatform. And I&#8217;m not just talking about Android or even OUYA (which we have a devkit for), but also PC, Mac, and even the big consoles (of which we&#8217;re already a licensed developer of one, and pending approval for a few others).</p>
<p>With that said, it takes a long time to develop games, and we don&#8217;t really have that much money saved up for me to do indie game development completely full-time, so I&#8217;m also looking for contract work. So if you need or know anyone who needs an experienced iOS or Unity developer, be sure to send them my way. <img src='http://www.tinytimgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyways, this is a big step. I&#8217;m both utterly terrified and completely excited. Hopefully, it won&#8217;t be long before you hear about some of our new projects that result from this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2013/06/14/full-time-indie/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Our Thoughts On OUYA</title>
		<link>http://www.tinytimgames.com/2013/03/04/our-thoughts-on-ouya/</link>
		<comments>http://www.tinytimgames.com/2013/03/04/our-thoughts-on-ouya/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 00:10:53 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[OUYA]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=902</guid>
		<description><![CDATA[In case you missed it, we chatted up Ben Gilbert from Engadget about our thoughts on OUYA and what it has in store for developers. You can read the article here.]]></description>
				<content:encoded><![CDATA[<p>In case you missed it, we chatted up Ben Gilbert from <a title="Engadget" href="http://www.engadget.com" target="_blank">Engadget</a> about our thoughts on <a title="OUYA" href="http://www.ouya.tv" target="_blank">OUYA</a> and what it has in store for developers. You can read the article <a title="OUYA Developers Sound Off" href="http://www.engadget.com/2013/02/01/ouya-developers-sound-off/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2013/03/04/our-thoughts-on-ouya/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Battles On Hold</title>
		<link>http://www.tinytimgames.com/2013/03/01/random-battles-on-hold/</link>
		<comments>http://www.tinytimgames.com/2013/03/01/random-battles-on-hold/#comments</comments>
		<pubDate>Fri, 01 Mar 2013 23:03:34 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Game 3]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=901</guid>
		<description><![CDATA[As those of you who have been following us may have already realized, we&#8217;ve put Random Battles on the backburner for the time being. We have other projects that we&#8217;re working on that have suddenly taken precedent, and we were running into some game design walls as well. We&#8217;d eventually like to come back to the [...]]]></description>
				<content:encoded><![CDATA[<p>As those of you who have been following us may have already realized, we&#8217;ve put Random Battles on the backburner for the time being. We have other projects that we&#8217;re working on that have suddenly taken precedent, and we were running into some game design walls as well. We&#8217;d eventually like to come back to the game, even if it&#8217;s in a slightly different form that we originally envisioned.</p>
<p>With that said, we&#8217;ve got a lot of things in the works for this year. So stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2013/03/01/random-battles-on-hold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Our Next Game</title>
		<link>http://www.tinytimgames.com/2012/06/12/our-next-game/</link>
		<comments>http://www.tinytimgames.com/2012/06/12/our-next-game/#comments</comments>
		<pubDate>Tue, 12 Jun 2012 20:02:35 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Game 3]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=887</guid>
		<description><![CDATA[We&#8217;re officially announcing our next game (and its real title) through this teaser trailer: You can check out TouchArcade&#8217;s first look at the game here. Still a ways to go on it yet, but it should be out near the end of this Summer.]]></description>
				<content:encoded><![CDATA[<p>We&#8217;re officially announcing our next game (and its real title) through this teaser trailer:</p>
<p><iframe width="600" height="338" src="http://www.youtube.com/embed/pguJTauZQqU?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>You can check out TouchArcade&#8217;s first look at the game <a title="TouchArcade preview" href="http://toucharcade.com/2012/06/12/wwdc-random-battles-impresses/">here</a>. Still a ways to go on it yet, but it should be out near the end of this Summer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2012/06/12/our-next-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Game 3 Updates, oDesk, and Developer Opinions</title>
		<link>http://www.tinytimgames.com/2012/03/15/game-3-updates-odesk-and-developer-opinions/</link>
		<comments>http://www.tinytimgames.com/2012/03/15/game-3-updates-odesk-and-developer-opinions/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 20:00:41 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Game 3]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=865</guid>
		<description><![CDATA[Game 3 is coming along nicely. We&#8217;re very close to being at the &#8220;vertical slice&#8221; stage, where we can actually get a real feel for how the whole game will play. We won&#8217;t have finalized graphics (especially on the UI side), but all game functionality should be there and working. Development hasn&#8217;t gone quite as [...]]]></description>
				<content:encoded><![CDATA[<p>Game 3 is coming along nicely. We&#8217;re very close to being at the &#8220;vertical slice&#8221; stage, where we can actually get a real feel for how the whole game will play. We won&#8217;t have finalized graphics (especially on the UI side), but all game functionality should be there and working.</p>
<p>Development hasn&#8217;t gone quite as fast as I would like, as implementing the game&#8217;s progression system was more complex than I had originally thought. But there are lots of other things happening with the game to keep motivation levels high.</p>
<p><span id="more-865"></span></p>
<h2>Hiring Artists on oDesk</h2>
<p>We took a big step in development a few weeks ago and decided to post a job on <a title="oDesk" href="http://www.odesk.com" target="_blank">oDesk</a>. As this was the first time we had ever attempted to work with others who we hadn&#8217;t actually worked with before in some other capacity, I was a bit skeptical that we would actually be able to find what we needed. However, the experience so far has been incredible!</p>
<p>We initially started with only a single job posting for a background artist, as we wanted to see what kind of response we would get. Over a single weekend, we had more than 70 applicants, and we ironically had a very long &#8220;short list&#8221; of applicants who we thought would fit the style we were looking for.</p>
<p>At the end of the day, we could only pick one applicant. So we narrowed down the short list, and came down to the two strongest ones. We asked them each to perform a (paid) test job, with the same tasks and requirements, and see how they handled it. Here&#8217;s the result of the background artist who we <strong>didn&#8217;t</strong> go with:</p>
<div id="attachment_866" class="wp-caption aligncenter" style="width: 550px"><a href="http://www.tinytimgames.com/wp-content/uploads/2012/03/Photo-Mar-15-5-16-04-PM.jpg"><img class="wp-image-866 " title="Game 3 Background Test" src="http://www.tinytimgames.com/wp-content/uploads/2012/03/Photo-Mar-15-5-16-04-PM-768x1024.jpg" alt="" width="540" height="721" /></a><p class="wp-caption-text">A test background from an oDesk applicant.</p></div>
<p>Now, if you&#8217;re like us, you probably think that looks really awesome! However, after a lot of deliberation, we decided the other artist&#8217;s test was much closer to what we were looking for. And very shortly, we had hired our very first art contractor! So far we have seven completed backgrounds (out of roughly 30 or so), and they all look amazing&#8230; but we&#8217;re not going to show our hand just yet. <img src='http://www.tinytimgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A pleasant side effect of having so many applicants is that we actually found an artist to draw up the rest of our game&#8217;s monsters. We simply created a private job in oDesk and invited the artist to it directly. We&#8217;re now on the second batch of monsters, and so far all of them are looking fantastic.</p>
<p>I think one of the reasons why we had such a strong response to our job posting is that we actually included a fair amount of reference art from the artist who had previously worked on the game (but who was sadly unavailable to finish &#8212; pesky day jobs with good pay). This let prospective artists immediately see the requirements for the job, as well as advertising how fun and rewarding the job could be. So if you&#8217;re on the lookout for contract artists, definitely include some reference art for your game. Remarkably, artists tend to be visual people!</p>
<h2>Marketing Opinions</h2>
<p>One of the things I&#8217;ve been wrestling with is how to market our game. We&#8217;ve got a unique gameplay mechanic that we need to make sure gets presented to players without having to explain it too much. We&#8217;ve got a couple of ideas on how to do this, but we&#8217;re a bit concerned on <strong>when</strong> we should start marketing blitz.</p>
<p>In the indie circles, it&#8217;s been said that talking early and often is the way to go, and I understand the reasoning behind it. However, I&#8217;m still concerned about showing our hand too early, partially because of our gameplay mechanic, but I also don&#8217;t like promising stuff and then not delivering it (something we&#8217;ve done in the past, unfortunately). Although, for that last one, we&#8217;ve gone past the point of no return considering how much we&#8217;ve put into the game. It&#8217;s really only a matter of time now&#8230;</p>
<p>So here&#8217;s my question to other developers in the audience: We&#8217;re about 2 to 2 1/2 months out from release; <em>when would you suggest we start talking about the game?</em> I realize we&#8217;ve already been talking about the game, but only in the vaguest terms &#8212; this would be more like, an actual name, trailers, images, and gameplay specifics. Should we start now? A month out from release? Four months ago? What?</p>
<p>That&#8217;s all for now. There&#8217;s a lot of work left to be done on Game 3, but it&#8217;s slowly starting to come together!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2012/03/15/game-3-updates-odesk-and-developer-opinions/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Cocos2D and Storyboards</title>
		<link>http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/</link>
		<comments>http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 03:37:18 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Cocos2D]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Game 3]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=851</guid>
		<description><![CDATA[UPDATE: I&#8217;ve now uploaded a ready-to-use class for your enjoyment to GitHub. Storyboarding in iOS 5 is really neat. It allows you to lay out nearly your entire interface visually, and gives you some neat features that simply make your life as a developer easier. Since our next game (an RPG) is going to be [...]]]></description>
				<content:encoded><![CDATA[<p><em>UPDATE: I&#8217;ve now uploaded <a title="CCViewController GitHub repo" href="https://github.com/tinytimgames/CCViewController" target="_blank">a ready-to-use class</a> for your enjoyment to GitHub.</em></p>
<p>Storyboarding in iOS 5 is really neat. It allows you to lay out nearly your entire interface visually, and gives you some neat features that simply make your life as a developer easier. Since our next game (an RPG) is going to be extremely UI-heavy, naturally we wanted to use Storyboarding to create our interface. The problem comes when it&#8217;s time to fire up Cocos2D and display our battle scenes.</p>
<p>However, with <a title="Cocos2D 2.0" href="https://github.com/cocos2d/cocos2d-iphone/tree/gles20" target="_blank">Cocos2D 2.0 (the OpenGL ES 2.0 version)</a> and iOS 5&#8242;s view controller containment functionality, integrating Cocos2D in a Storyboard is actually very trivial.</p>
<p><span id="more-851"></span></p>
<h3>Containing Cocos2D</h3>
<p>Let&#8217;s start by creating a new class called CocosViewController, which derives from UIViewController. It should also conform to the CCDirectorDelegate protocol.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;cocos2d.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> CocosViewController <span style="color: #002200;">:</span> UIViewController &lt;CCDirectorDelegate&gt;
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>So far, so good. Now, there&#8217;s something important to note about Cocos2D 2.0&#8242;s director, especially if you&#8217;re used to 1.x: The 2.0 director actually derives from UIViewController! This makes it incredibly easy to add a Cocos2D view to our hierarchy.</p>
<p>Over in the implementation file, you&#8217;ll want to set up your viewDidLoad method like so:</p>

<div class="wp_syntax"><table><tr><td class="code"><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>viewDidLoad
<span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;
&nbsp;
    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>;
&nbsp;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>director isViewLoaded<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> <span style="color: #a61390;">NO</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #11740a; font-style: italic;">// Create the OpenGL view that Cocos2D will render to.</span>
        CCGLView <span style="color: #002200;">*</span>glView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCGLView viewWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> keyWindow<span style="color: #002200;">&#93;</span> bounds<span style="color: #002200;">&#93;</span>
                                       pixelFormat<span style="color: #002200;">:</span>kEAGLColorFormatRGB565
                                       depthFormat<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span>
                                preserveBackbuffer<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span>
                                        sharegroup<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span>
                                     multiSampling<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span>
                                   numberOfSamples<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
&nbsp;
        <span style="color: #11740a; font-style: italic;">// Assign the view to the director.</span>
        director.view <span style="color: #002200;">=</span> glView;
&nbsp;
        <span style="color: #11740a; font-style: italic;">// Initialize other director settings.</span>
        <span style="color: #002200;">&#91;</span>director setAnimationInterval<span style="color: #002200;">:</span>1.0f<span style="color: #002200;">/</span>60.0f<span style="color: #002200;">&#93;</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;">&#125;</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Set the view controller as the director's delegate, so we can respond to certain events.</span>
    director.delegate <span style="color: #002200;">=</span> self;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Add the director as a child view controller of this view controller.</span>
    <span style="color: #002200;">&#91;</span>self addChildViewController<span style="color: #002200;">:</span>director<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Add the director's OpenGL view as a subview so we can see it.</span>
    <span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>director.view<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>self.view sendSubviewToBack<span style="color: #002200;">:</span>director.view<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Finish up our view controller containment responsibilities.</span>
    <span style="color: #002200;">&#91;</span>director didMoveToParentViewController<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Run whatever scene we'd like to run here.</span>
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>director.runningScene<span style="color: #002200;">&#41;</span>
        <span style="color: #002200;">&#91;</span>director replaceScene<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>MyScene scene<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">else</span>
        <span style="color: #002200;">&#91;</span>director runWithScene<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>MyScene scene<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>And so that we&#8217;re nice and polite programmers, we&#8217;ll clean up after ourselves:</p>

<div class="wp_syntax"><table><tr><td class="code"><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>viewDidUnload
<span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>super viewDidUnload<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CCDirector sharedDirector<span style="color: #002200;">&#93;</span> setDelegate<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>And that is quite literally all of the code that you need to write to get the basics up and running. Let me explain a little bit about what&#8217;s going on.</p>
<p>In viewDidLoad, we first check to see if the director&#8217;s view has been loaded. Remember that the Cocos2D director is now simply a subclass of UIViewController, so we can use methods like isViewLoaded to get information that we need. If the view hasn&#8217;t been loaded, that means we haven&#8217;t created an OpenGL view for the director yet, so we do that if necessary.</p>
<p>After that, we do the real magic, which uses iOS 5&#8242;s view controller containment. We first add the director as a child view controller. Doing this means that the director&#8217;s viewWillAppear:, viewWillDisappear:, et al will be called properly, and in Cocos2D 2.0, that means that the director will automatically pause and unpause itself when the view controller disappears or appears. Awesome!</p>
<p>We then add the director&#8217;s view (the OpenGL view) to our view controller&#8217;s view hierarchy and send it to the back. Sending it to the back allows us to place buttons and other UIKit stuff on top of the OpenGL view in Interface Builder. Finally, we need to call the director&#8217;s didMoveToParentViewController: method, as required for view controller containment. We then run our scene, and that&#8217;s it!</p>
<h3>Adding Cocos2D to a Storyboard</h3>
<p>Here we have a perfectly normal Storyboard, with a navigation controller and a view controller that has a simple button.</p>
<p style="text-align: center;"><a href="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.03.31-PM.png"><img class="aligncenter  wp-image-852" title="Screen Shot 2012-02-07 at 7.03.31 PM" src="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.03.31-PM.png" alt="" width="562" height="408" /></a></p>
<p>Now let&#8217;s drag a new view controller onto the canvas,</p>
<p style="text-align: center;"><a href="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.14.26-PM.png"><img class="aligncenter  wp-image-853" title="Screen Shot 2012-02-07 at 7.14.26 PM" src="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.14.26-PM.png" alt="" width="413" height="409" /></a></p>
<p>and assign its class to the one we just created.</p>
<p><a href="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.14.55-PM.png"><img class="aligncenter size-full wp-image-854" title="Screen Shot 2012-02-07 at 7.14.55 PM" src="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.14.55-PM.png" alt="" width="327" height="317" /></a></p>
<p>Set up a segue between the button and our new view controller. Set the segue type to &#8220;Push&#8221; for now.</p>
<p style="text-align: center;"><a href="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.15.33-PM.png"><img class="aligncenter  wp-image-855" title="Screen Shot 2012-02-07 at 7.15.33 PM" src="http://www.tinytimgames.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-07-at-7.15.33-PM.png" alt="" width="500" height="399" /></a></p>
<p>And now, just build and run! You should be able to press the button to load your Cocos2D scene, press the back button to stop it, and repeat the process over and over again! You can even add a button to the CocosViewController if you&#8217;d like.</p>
<h3>Some Notes</h3>
<p>As you may have noticed, Cocos2D&#8217;s initialization happens whenever CocosViewController is first pushed onto the navigation stack (aka, lazy loading). You may prefer to initialize Cocos2D right at launch to minimize the initial delay.</p>
<p>Also note that if you want to have Cocos2D in the background and have a navigation controller on top (so that you can have a navigation structure for your pause menu, for example), you&#8217;ll need to add another navigation controller as a child view controller. View controller containment isn&#8217;t really supported in Interface Builder, sadly, so if you do this, you&#8217;ll probably want to create another storyboard file and load it as your child view controller.</p>
<p>Additionally, there may be some gotchas with this code that I just don&#8217;t know about, as it&#8217;s only had minimal testing. So let me know if you run into any troubles, and I&#8217;ll try to keep the post updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
		<item>
		<title>Here&#8217;s the Plan</title>
		<link>http://www.tinytimgames.com/2012/02/02/heres-the-plan/</link>
		<comments>http://www.tinytimgames.com/2012/02/02/heres-the-plan/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 18:07:14 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Game 3]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=848</guid>
		<description><![CDATA[In my last post, I listed my 2012 indie game dev resolutions. So far, things have been going well. I&#8217;m working on the game that I want to make, and it looks like I&#8217;ll be able to finish it this year (in fact, more likely within the first half of this year). The only bit [...]]]></description>
				<content:encoded><![CDATA[<p>In <a title="New Year’s Resolutions" href="http://www.tinytimgames.com/2012/01/05/new-years-resolutions/" target="_blank">my last post</a>, I listed my 2012 indie game dev resolutions. So far, things have been going well. I&#8217;m working on the game that I want to make, and it looks like I&#8217;ll be able to finish it this year (in fact, more likely within the first half of this year). The only bit that hasn&#8217;t gone so well is &#8220;being more social&#8221;. My plan was to go to GDC this year and chat with other iOS developers, but due to my day job I won&#8217;t be able to make it this year. Oh well, there&#8217;s always WWDC.</p>
<p>There was a bit of a setback on progress as my daughter, my wife, and myself all got the nasty stomach virus that&#8217;s been sweeping across the country lately. While it was only a 24-hour illness, recovery took quite a bit longer. However, unlike before when I would have a break in development and have trouble getting started again, I was able to jump right back into it once I was able. How was I able to accomplish this seemingly impossible task?! Why, through planning, of course!</p>
<p><span id="more-848"></span></p>
<h3>Having A Plan</h3>
<p>It&#8217;s important to note that both Sheepstacker and Word Monkey were made without any planning or design documents. I began work on their prototypes, saw that they were good, and just continued on until we said, &#8220;Now <em>this</em> is a game!&#8221; Essentially, the entirety of the game designs had to be kept in my brain. And as you may know, the brain can sometimes conveniently forget things (especially my brain).</p>
<p>For this new game (which I&#8217;m calling TTG3 until its official unveiling), I realized that this method of scattershot design just simply wasn&#8217;t going to work. The game is somewhat of an RPG, and it&#8217;s made up of many independent gameplay systems and stats that all need to work together in a logical way. Additionally, we&#8217;ve decided that we&#8217;re going to hire contractors for the artwork instead of using pre-made art, and working with contractors means you really need to have a clear plan. Otherwise, you&#8217;re wasting the contractor&#8217;s time and your money.</p>
<p>So I started by creating a bunch of tickets in my issue tracker. I use <a title="Lighthouse" href="http://www.lighthouseapp.com" target="_blank">Lighthouse</a> due to the fact that it&#8217;s incredibly streamlined, allowing me to focus on the tasks and not on management. Each of these tickets is something like, &#8220;Create the design for the battle system&#8221; or &#8220;Create the design for player progression&#8221;. In other words, each ticket is focused on a single chunk of the game&#8217;s complete design.</p>
<p>At first, I began assembling a massive &#8220;game design bible&#8221; that was to include every minute detail of the game, down to the very stats of each character in the game. I quickly found that I was spending more time trying to organize the document than actually trying to write it. Instead, I decided to create a single document for each of the tickets I had created earlier. This way, each document remained focused on a single gameplay system. I also decided to keep the design documents in <a title="Google Docs" href="http://docs.google.com" target="_blank">Google Docs</a> so I can access and make changes to them from anywhere. Additionally, I can link to the actual documents in the tickets to easily reference them.</p>
<p>So far, this has worked wonderfully. It has not only kept me focused on a single task at a time, but it&#8217;s also helped me to plan out every feature of the game ahead of time. It&#8217;s important to note that these documents won&#8217;t always be strictly adhered to (as game development requires fluidity and adaptability); they&#8217;re simply guides for when I inevitably get to a point in production where I don&#8217;t know what to work on next.</p>
<h3>Executing the Plan</h3>
<p>Naturally, the next phase of development is to actually execute the plan I&#8217;ve laid out. Since we already know the requirements for the in-game art, we&#8217;ll be able to start the search for artists as early as next week.</p>
<p>We&#8217;ll be handling UI art a bit differently. Since the game is an RPG and is thus very menu- and UI-based, we&#8217;re going to prototype all of the UI for the entire game with temp art, work out the kinks, and then finalize our design before sending it off to someone to beautify it.</p>
<p>The overall plan for the next phase of development is to have all gameplay systems implemented and all UI prototyped in roughly a month. We&#8217;ve got a lot of work ahead of us, but with a good solid plan in place, I think we&#8217;ll definitely be able to do it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2012/02/02/heres-the-plan/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New Year&#8217;s Resolutions</title>
		<link>http://www.tinytimgames.com/2012/01/05/new-years-resolutions/</link>
		<comments>http://www.tinytimgames.com/2012/01/05/new-years-resolutions/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 21:26:17 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Game 3]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=829</guid>
		<description><![CDATA[So it&#8217;s been a while since I&#8217;ve written anything for #iDevBlogADay, or indeed this blog in general. But it&#8217;s a brand new year, and thus a chance for new beginnings! This post is going to be about my indie game development New Year&#8217;s Resolutions; three things that I&#8217;ve resolved myself to doing in 2012 for [...]]]></description>
				<content:encoded><![CDATA[<p>So it&#8217;s been a while since I&#8217;ve written anything for <a title="#iDevBlogADay" href="http://idevblogaday.com" target="_blank">#iDevBlogADay</a>, or indeed this blog in general. But it&#8217;s a brand new year, and thus a chance for new beginnings!</p>
<p>This post is going to be about my indie game development New Year&#8217;s Resolutions; three things that I&#8217;ve resolved myself to doing in 2012 for Tiny Tim Games. If nothing else, it&#8217;ll give a sense of where I would hopefully like to go this year, and also possibly motivate you to make your own indie game dev resolutions.</p>
<p><span id="more-829"></span></p>
<h2>1. Release at least one new game in 2012</h2>
<p>So 2011 was a rough year for Tiny Tim Games, as we had no new releases, lots of false starts, and lots of things to distract us from working on games (daughter, day job, etc). The thing is, these things are still here, and until we make bajillions from one of our future breakout hits, that situation isn&#8217;t going to change.</p>
<p>But I still have the passion to be creative. I still want to create my own worlds for others to play in and enjoy. So my first resolution is to release a brand new Tiny Tim Game in 2012. Hopefully, giving ourselves an entire year to accomplish the goal will help the time not be so stressful. After all, our 9 month old daughter is about one step away from walking, so finding additional development time isn&#8217;t going to come easy.</p>
<h2>2. Work on the game I WANT to make</h2>
<p>This sounds like a natural thing to do. I mean, isn&#8217;t that why you become indie? To make the games you actually want to make? Well, after the very modest success of Sheepstacker and Word Monkey, I had wanted to make a few games that were quick and simple and could possibly generate some cash flow for us to work on some of our more ambitious projects.</p>
<p>The problem with this is that I didn&#8217;t really have any passion for those projects. Safety First, Sol Defender. While they each had some interesting qualities about them, and I may want to return to parts of them in the future, there has been one game I&#8217;ve been wanting to do since mid-2009.</p>
<p>It&#8217;s always seemed too ambitious though, at least from an artistic standpoint. We&#8217;ve already spent quite a lot of money trying to bring the game to life, only to end up with 1/3 of the art we need, and no way of funding the remainder of the project. But it&#8217;s the project I most want to do and have wanted to do for a year and a half now. So I&#8217;m committing myself to finding some way to make it happen.</p>
<p>One thing I&#8217;ll be doing to make this happen is to leverage pre-made art from online sources. Personally, I&#8217;d rather have completely original art, but as I&#8217;m not an artist and I can&#8217;t afford one, I don&#8217;t really see any other option. I&#8217;m guessing the greater population of iOS gamers don&#8217;t browse TurboSquid or the Unity Asset Store, so the chance of them running into these assets in the wild is pretty small.</p>
<h2>3. Be more social</h2>
<p>As I&#8217;m quite shy, I&#8217;m really bad a networking. I just don&#8217;t have the ability to walk into a room full of people and join in on a conversation. Unfortunately, if no one knows about you, it&#8217;s really hard to get the word out about games.</p>
<p>So I&#8217;m challenging myself to be more active in the indie game dev community. I haven&#8217;t been to any of the conferences over the past few years (partially due to lack of funds), but I never really placed them as a priority. My plan this year is to hit both GDC and WWDC, and maybe a smaller conference here or there. I&#8217;ll also be trying to blog more regularly (with the help of #iDevBlogADay), especially about the new project.</p>
<p>That&#8217;s all for this time. Hopefully, my next post will have some tantalizing information about the new game. See  you then!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2012/01/05/new-years-resolutions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Unity Plugins and UIApplicationDidFinishLaunchingNotifcation</title>
		<link>http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/</link>
		<comments>http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 21:15:36 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iDevBlogADay]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=826</guid>
		<description><![CDATA[I&#8217;m taking a break from my Cocos2D-related posts for this #iDevBlogADay entry. With that said, while this post will be talking specifically about creating Unity plugins, the knowledge can still be used to aid in creating standalone plugins for Cocos2D as well. So you&#8217;re writing your Unity plugin to do some cool native functionality, but [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m taking a break from my <a title="Cocos2D and ARC" href="http://www.tinytimgames.com/2011/07/22/cocos2d-and-arc/" target="_blank">Cocos2D</a>-<a title="Introducing CCKit" href="http://www.tinytimgames.com/2011/08/05/introducing-cckit/" target="_blank">related</a> <a title="Extending CCNode" href="http://www.tinytimgames.com/2011/08/19/extending-ccnode/" target="_blank">posts</a> for this <a title="#iDevBlogADay" href="http://idevblogaday.com" target="_blank">#iDevBlogADay</a> entry. With that said, while this post will be talking specifically about creating Unity plugins, the knowledge can still be used to aid in creating standalone plugins for Cocos2D as well.</p>
<p>So you&#8217;re writing your Unity plugin to do some cool native functionality, but you really need it to do some work right when the app launches. There are usually two ways to solve this problem: 1) Create an &#8220;init&#8221; function that you call from Unity script when your first scene is loaded, or worse 2) modify <em>application:didFinishLaunchingWithOptions:</em> directly. Technically, there&#8217;s a third option too, involving creating a category of the AppController delegate and &#8220;overriding&#8221; <em>application:didFinishLaunchingWithOptions:</em>. The OpenFeint Unity plugin uses this method, actually, but as I mentioned in a previous post, this has some serious drawbacks, especially if you want to use the technique more than once (and yes, I realize I&#8217;m the one who originally wrote that plugin&#8230; I didn&#8217;t know!).</p>
<p>I&#8217;d like to introduce you to the <em>UIApplicationDidFinishLaunchingNotification</em> key, something which has become a good friend of mine.</p>
<p><span id="more-826"></span>It always bugged me that the <em>UIApplicationDidFinishLaunchingNotification</em> key existed. I couldn&#8217;t possibly think of a use for it. In my mind, the first place that any application code could ever run was in <em>application:didFinishLaunchingWithOptions:</em> (or its precursor, <em>applicationDidFinishLaunching:</em>), and so the key was not necessary. I assumed it was just some thing require by the OS that we weren&#8217;t really supposed to use.</p>
<p>But one day, I decided to actually investigate the uses of this key instead of basing my assumptions on pure speculation. I found the <em>NSObject</em> class method <em>load</em>. Suddenly, the key started to make sense.</p>
<p>The documentation for <em>load</em> says that the method is &#8220;invoked whenever a class or category is added to the Objective-C runtime; implement this method to perform class-specific behavior upon loading.&#8221; Essentially, what this means is that any code inside your class&#8217;s <em>load</em> class method will be executed <strong>before</strong> <em>application:didFinishLaunchingWithOptions:</em>. If you want to write any startup code, this seems like it would be the place to do it. But there is a caveat: Other classes may not have loaded themselves yet, so it&#8217;s not safe to do too much in this method.</p>
<p>Instead, you should add your class as an observer of the <em>UIApplicationDidFinishLaunchingNotification</em> key with an action method to do any initialization you want. This will allow all classes to be fully loaded, but still allow for initialization code to be run without having to have either an initialization function in Unity script or by modifying AppController&#8217;s <em>application:didFinishLaunchingWithOptions:</em>.</p>
<p>Here&#8217;s an example:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> MyCoolPlugin <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Class stuff.</span>
&nbsp;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #a61390;">static</span> MyCoolPlugin <span style="color: #002200;">*</span>_sharedInstance <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
<span style="color: #a61390;">@implementation</span> MyCoolPlugin
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>load
<span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNotificationCenter</span> defaultCenter<span style="color: #002200;">&#93;</span> addObserver<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>createMyCoolPlugin<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span>
        name<span style="color: #002200;">:</span>UIApplicationDidFinishLaunchingNotification object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>createMyCoolPlugin<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSNotification</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>notification
<span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// This code will be called immediately after application:didFinishLaunchingWithOptions:.</span>
    <span style="color: #11740a; font-style: italic;">// You could use this to create an instance of your plugin class, like so:</span>
    _sharedInstance <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MyCoolPlugin alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Your plugin methods.</span>
&nbsp;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// C functions to access your plugin from Unity script.</span></pre></td></tr></table></div>

<p>Not only can you use <em>UIApplicationDidFinishLaunchingNotification</em>, but you can also observe keys like <em>UIApplicationDidEnterBackgroundNotification</em>. Essentially, you can plug into most of <em>UIApplicationDelegate</em>&#8216;s methods without having to modify Unity&#8217;s AppController. And naturally, if you&#8217;re creating standalone Objective-C libraries, this method is essentially required unless you want your users to modify their app delegate.</p>
<p>That&#8217;s all for this week. For my next post in two weeks, we should have some very exciting news to share about a project we&#8217;ve been working on!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/09/01/unity-plugins-and-uiapplicationdidfinishlaunchingnotifcation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extending CCNode</title>
		<link>http://www.tinytimgames.com/2011/08/19/extending-ccnode/</link>
		<comments>http://www.tinytimgames.com/2011/08/19/extending-ccnode/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 18:47:15 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Cocos2D]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iDevBlogADay]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=824</guid>
		<description><![CDATA[If  you&#8217;re using Cocos2D, for the most part you&#8217;ll be using CCSprite and other CCNode-derived classes as is. If you need to make extensions to these classes, you simply make a subclass derived from those classes and write only what you need. But what if you need to extend CCNode itself? You could subclass CCNode, [...]]]></description>
				<content:encoded><![CDATA[<p>If  you&#8217;re using Cocos2D, for the most part you&#8217;ll be using CCSprite and other CCNode-derived classes as is. If you need to make extensions to these classes, you simply make a subclass derived from those classes and write only what you need.</p>
<p>But what if you need to extend CCNode itself? You could subclass CCNode, but then CCSprite and other subclasses wouldn&#8217;t get the benefits of your subclass. You could modify the CCNode source code, but if you update to a future version of Cocos2D, you&#8217;re likely to run into merge problems or (worse) lose all of your changes.</p>
<p>This is where we can leverage the fact that Cocos2D is written in Objective-C. The language provides lots of excellent features that allow us to extend a pre-existing class without subclassing.</p>
<h3><span id="more-824"></span>Category Extensions</h3>
<p>If you&#8217;ve been working with Objective-C for very long, you&#8217;ve probably come into contact with the concept of categories. In a nutshell, a category allows you to add methods to an existing class, even if you don&#8217;t have the source code for that class. Categories are simple enough to use. In your header file, you simply declare the category like so:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> CCNode <span style="color: #002200;">&#40;</span>MyExtensions<span style="color: #002200;">&#41;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>myExtensionMethod;
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>In this example, <strong>MyExtensions</strong> is the name of the category. Then, in your implementation file:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@implementation</span> CCNode <span style="color: #002200;">&#40;</span>MyExtensions<span style="color: #002200;">&#41;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>myExtensionMethod
<span style="color: #002200;">&#123;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Do something interesting here.</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>So now, on any CCNode (or any subclass derived from CCNode, including CCSprite), you can do something like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;">CCSprite <span style="color: #002200;">*</span>aSprite <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;test.png&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>aSprite myExtensionMethod<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>You can also override methods in CCNode with a category, but you have to be very careful with this. In fact, Apple says this is &#8220;strongly discouraged&#8221;. The problem arises when you have two categories trying to override the same method. The method that takes precedence is not defined.</p>
<p>So as you see, categories can be pretty useful, but they do have one particularly annoying limitation: You can&#8217;t add member variables to a class through a category. This becomes extremely limiting when you need to add something like per-instance storage of an array or reference. However, there&#8217;s another (more advanced) feature of Objective-C we can use to get around this limitation.</p>
<h3>Associative References</h3>
<p>There is a set of Objective-C runtime functions that allows you to create <em>associative references</em>. Basically, it allows you to make an association between one object and another, usually to simulate the addition of object instance variables to an existing class without having to modify the original class.</p>
<p>Let&#8217;s use an example from <a title="Introducing CCKit" href="http://www.tinytimgames.com/2011/08/05/introducing-cckit/" target="_blank">CCKit</a> to illustrate how to get this working. In CCGestureRecognizer, we need to keep track of all of the gesture recognizers that have been added to a CCNode. Before, we would have to go into the CCNode code and add an NSMutableArray to the class declaration. However, since CCKit is a set of standalone classes, this approach wouldn&#8217;t work.</p>
<p>So in the <strong>addGestureRecognizer:</strong> method (which is part of a CCNode category called GestureRecognizerAddtions), we do something like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// A key to access the associative reference.</span>
<span style="color: #a61390;">static</span> <span style="color: #a61390;">char</span> CCNodeGestureRecognizerAdditionsKey;
&nbsp;
<span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span>gestureRecognizers <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableArray</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>gestureRecognizers addObject<span style="color: #002200;">:</span>gestureRecognizer<span style="color: #002200;">&#93;</span>;
&nbsp;
objc_setAssociatedObject<span style="color: #002200;">&#40;</span>self, <span style="color: #002200;">&amp;</span>amp;CCNodeGestureRecognizerAdditionsKey, gestureRecognizers, OBJC_ASSOCIATION_RETAIN<span style="color: #002200;">&#41;</span>;</pre></td></tr></table></div>

<p>As you can see, we created an NSMutableArray, added an object to it, and then called the Objective-C runtime function <strong>objc_setAssociatedObject</strong>. The first parameter is the object you want to associate with (in this case, a CCNode), the second is a key with which you&#8217;ll access the associated object (the key must be a void pointer, so we create a static variable here for simplicity), the third is the actual object we want to associate, and the last parameter is the association policy. As you can probably guess, the association policy is similar to property attributes. The above is essentially like declaring this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>retain<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span>gestureRecognizers;    <span style="color: #11740a; font-style: italic;">// &quot;strong&quot; would replace &quot;retain&quot; in ARC.</span></pre></td></tr></table></div>

<p>So we&#8217;ve set up the association. How do we access the object?</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span>gestureRecognizers <span style="color: #002200;">=</span> objc_getAssociatedObject<span style="color: #002200;">&#40;</span>self, <span style="color: #002200;">&amp;</span>amp;CCNodeGestureRecognizerAdditionsKey<span style="color: #002200;">&#41;</span>;</pre></td></tr></table></div>

<p>And that&#8217;s it! We just added a member variable to CCNode without actually changing its source code! Additionally, the array will be released when the CCNode is deallocated, so it even cleans up after itself.</p>
<p>Of course, you&#8217;ll only want to use this in certain situations. But if you need to extend the functionality of CCNode by adding member variables, and a subclass won&#8217;t work for you, associative references are an excellent way to accomplish what you need.</p>
<h3>CCKit Updates</h3>
<p>If you&#8217;ve been watching the <a title="CCKit" href="http://github.com/jerrodputman/CCKit" target="_blank">CCKit project over on GitHub</a>, you may have noticed a flurry of commits in the past few days. A few of those commits were critical bug fixes, so I suggest you grab the latest. But there was also some new functionality included: the CCNavigationController class!</p>
<p>This class is a Cocos2D version of UINavigationController. It was designed with menu sequences in mind, but it could be used for almost anything I suppose. Basically, you create the navigation controller with a root node (any CCNode-derived subclass that implements the CCRGBAProtocol will work, i.e., CCSprite or CCMenu). You can then push and pop nodes onto and off of the navigation stack, just like with a UINavigationController. There&#8217;s even an appropriate animation effect to go with it.</p>
<p>So if you need to create a hierarchical main menu for your next game, CCNavigationController may fit your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/08/19/extending-ccnode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
