<?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 &#187; Development</title>
	<atom:link href="http://www.tinytimgames.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tinytimgames.com</link>
	<description>Just For Fun</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:41:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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[iDevBlogADay]]></category>
		<category><![CDATA[TTG3]]></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[iDevBlogADay]]></category>
		<category><![CDATA[TTG3]]></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"><div 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></div></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>0</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"><div 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></div></div>

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

<div class="wp_syntax"><div 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></div></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"><div 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></div></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"><div 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></div></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"><div 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></div></div>

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

<div class="wp_syntax"><div 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></div></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>
		<item>
		<title>Introducing CCKit</title>
		<link>http://www.tinytimgames.com/2011/08/05/introducing-cckit/</link>
		<comments>http://www.tinytimgames.com/2011/08/05/introducing-cckit/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 18:09:46 +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=822</guid>
		<description><![CDATA[While working on our new Cocos2D-based project we&#8217;ve talked about in previous posts, we came to the point where we needed to implement the Cocos equivalent of a UIScrollView. While we found a few community-created solutions, none of them really matched the intuitiveness and fluidity of Apple&#8217;s own UIScrollView. What I&#8217;m going to talk about [...]]]></description>
			<content:encoded><![CDATA[<p>While working on our new Cocos2D-based project we&#8217;ve talked about in previous posts, we came to the point where we needed to implement the Cocos equivalent of a UIScrollView. While we found a few community-created solutions, none of them really matched the intuitiveness and fluidity of Apple&#8217;s own UIScrollView.</p>
<p>What I&#8217;m going to talk about in this <a title="#iDevBlogADay" href="http://idevblogaday.com" target="_blank">#iDevBlogADay</a> post is a new set of classes I&#8217;m calling CCKit. The purpose of the library is to bridge the gap between Cocos2D and Apple&#8217;s UIKit classes. The library includes classes like CCScrollLayer (UIScrollView emulation) and CCTableLayer (UITableView emulation) which should give very close approximations to the UIKit equivalents. Additionally, the library is <a title="CCKit on GitHub" href="http://github.com/jerrodputman/CCKit" target="_blank">open source and hosted on GitHub</a>, so feel free to include it in your own projects and even contribute if you&#8217;d like.</p>
<h3><span id="more-822"></span>CCScrollLayer</h3>
<p>The CCScrollLayer class (and both CCTableLayer and CCTableLayerCell classes) are derived from code written by Sangwoo Im in his <a title="CCTableViewSuite" href="http://www.cocos2d-iphone.org/archives/943" target="_blank">CCTableViewSuite</a>. The original code has provided a lot of Cocos2D-based games with good UITableView approximations. While the table view implementation feels pretty good, I felt that the scroll view implementation could go a bit further.</p>
<p>The CCScrollLayer class in CCKit supports nearly all of the features of Apple&#8217;s UIScrollView class, including bouncing, deceleration, and pinch-to-zoom. There are a few features missing (such as paging and directional lock) that will be added over time. I spent a lot of time playing around with values trying to get the bouncing and deceleration to feel correct. The zoom also properly mimics zooming in and out from the centroid of the two touches on the screen instead of just from the center of the screen (which is a personal pet peeve of mine).</p>
<p>Panning and zooming are implemented with gesture recognizers. I apologize to those wanting to deploy for targets below 3.2, but the benefits of using gesture recognizers are too numerous. For one, you can use your own gesture recognizers in cooperation with the recognizers for the scroll layer, and even set up dependencies between them (i.e., don&#8217;t pan if a long press is detected first).</p>
<p>Other than the aforementioned features, a CCScrollLayer works pretty much like any other CCLayer, which means you can add all of your sprites (and even other layers) to it. Here&#8217;s how to set one up:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">CCScrollLayer <span style="color: #002200;">*</span>scrollLayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCScrollLayer scrollLayerWithViewSize<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><span style="color: #002200;">&#93;</span>;
scrollLayer.contentSize <span style="color: #002200;">=</span> CGSizeMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">5000</span>, <span style="color: #2400d9;">5000</span><span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Add whatever you want to the scroll layer using addChild:</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Add the layer to the scene.</span>
<span style="color: #002200;">&#91;</span>scene addChild<span style="color: #002200;">:</span>scrollLayer<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h3>CCTableLayer</h3>
<p>CCTableLayer is still a work-in-progress, and as such isn&#8217;t ready for primetime yet. We need a UITableView implementation for our game, though, so it should be coming soon.</p>
<h3>CCGestureRecognizer</h3>
<p>This class was originally written by <a title="Original CCGestureRecognizer implementation" href="http://www.cocos2d-iphone.org/forum/topic/8929" target="_blank">Joe Allen</a>. Most of my changes involved cleaning up the public interface so only the functionality necessary to use the class was exposed. The original implementation also required modifying code in CCNode. I&#8217;ve removed that requirement by putting the changes in a category extension.</p>
<p>The class essentially acts as a wrapper for a UIGestureRecognizer. In fact, the only real functionality this class provides is the ability for your gesture recognizers to respond to node touches instead of just view touches. Now, for instance, you can set up UITapGestureRecognizers on your sprites and have each sprite respond to the tap only if it was touched.</p>
<p>Here&#8217;s how to set one up:</p>

<div class="wp_syntax"><div 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>onEnterTransitionDidFinish
<span style="color: #002200;">&#123;</span>
   <span style="color: #002200;">&#91;</span>super onEnterTransitionDidFinish<span style="color: #002200;">&#93;</span>;
&nbsp;
   UITapGestureRecognizer <span style="color: #002200;">*</span>tapGestureRecognizer <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> init<span style="color: #002200;">&#93;</span>;
&nbsp;
   <span style="color: #11740a; font-style: italic;">// Set up the tap gesture recognizer like you normally would.</span>
&nbsp;
   <span style="color: #11740a; font-style: italic;">// You'll want to retain ccRecognizer for later use.</span>
   CCGestureRecognizer <span style="color: #002200;">*</span>ccRecognizer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCGestureRecognizer recognizerWithRecognizer<span style="color: #002200;">:</span>tapGestureRecognizer target<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>handleTapGesture<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
   <span style="color: #002200;">&#91;</span>self addGestureRecognizer<span style="color: #002200;">:</span>ccRecognizer<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>onExit
<span style="color: #002200;">&#123;</span>
   <span style="color: #002200;">&#91;</span>super onExit<span style="color: #002200;">&#93;</span>;
&nbsp;
   <span style="color: #002200;">&#91;</span>self removeGestureRecognizer<span style="color: #002200;">:</span>ccRecognizer<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>handleTapGesture<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITapGestureRecognizer <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>gestureRecognizer
<span style="color: #002200;">&#123;</span>
   <span style="color: #11740a; font-style: italic;">// Do something when this sprite/node is tapped on!</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>If you look in the CCScrollLayer.m file, you&#8217;ll see that it&#8217;s using the CCGestureRecognizer class to set up its UIPanGestureRecognizer and UIPinchGestureRecognizer.</p>
<h3>More To Come</h3>
<p>For the time being, the code is made with ARC in mind. If you try to run this in a non-ARC project, you&#8217;ll probably leak memory everywhere. Apple has made it clear that ARC is the future of iOS development. There&#8217;s going to be a dearth of ARC-compatible source code samples when iOS 5 is made public, so I&#8217;m hoping we can start filling that void.</p>
<p>As mentioned before, this library is a work-in-progress and will be added to on a constant basis. I can tell you that from our end, we&#8217;ll add things as we need them in our own games. However, if you have something you&#8217;d like to contribute, then feel free to send a pull request. Just remember that the library is solely for mimicking or allowing access to Apple&#8217;s UIKit functionality in Cocos2D.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/08/05/introducing-cckit/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Cocos2D and ARC</title>
		<link>http://www.tinytimgames.com/2011/07/22/cocos2d-and-arc/</link>
		<comments>http://www.tinytimgames.com/2011/07/22/cocos2d-and-arc/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 08:04:59 +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=818</guid>
		<description><![CDATA[UPDATE: The changes outlined in this post have now been merged into the main Cocos2D develop tree, so you should grab from there as I will no longer be maintaining a separate repo for this. You will still need to follow the steps below to include Cocos2D in your project, or you can follow the [...]]]></description>
			<content:encoded><![CDATA[<p><em>UPDATE: The changes outlined in this post have now been merged into the main <a title="Cocos2D on Github" href="https://github.com/cocos2d/cocos2d-iphone" target="_blank">Cocos2D develop tree</a>, so you should grab from there as I will no longer be maintaining a separate repo for this.</em></p>
<p><em>You will still need to follow the steps below to include Cocos2D in your project, or you can follow the instructions listed <a title="Turning off ARC for specific files" href="http://stackoverflow.com/questions/6308425/ios-5-best-practice-release-retain/6429909#6429909" target="_blank">here</a> to simply turn ARC off for just the Cocos2D files.</em></p>
<p>This is my very first post for <a title="#iDevBlogADay" href="http://www.idevblogaday.com" target="_blank">#iDevBlogADay</a>. I had been scheduled to do it earlier this year, but then <a href="https://twitter.com/jerrodputman/status/50166231793278976" target="_blank">something happened</a>. I&#8217;m not exactly torn up about it. <img src='http://www.tinytimgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In my <a title="Diversion" href="http://www.tinytimgames.com/2011/06/28/diversion/" target="_blank">last post</a>, I mentioned a new project that we&#8217;re attempting to do before we hop back on to Sol Defender. We decided <a title="Cocos2D" href="http://www.cocos2d-iphone.org" target="_blank">Cocos2D</a> was the right fit for the project, as the game simply works better in 2D. We also really wanted to use a lot of the new features coming in <a title="What's New in iOS 5" href="http://developer.apple.com/technologies/ios5/" target="_blank">iOS 5</a>, which while technically accessible to Unity through plugin &#8220;glue code&#8221; is simply quicker and easier to access if you&#8217;re working entirely in Objective-C.</p>
<p>Due to the iOS 5 requirement, I specifically wanted to start using ARC (automatic reference counting) as I (and Apple) thinks this is the way to go moving forward regarding Objective-C. If you don&#8217;t know about ARC, I suggest you read up on it a bit, but in a nutshell, it reduces (eliminates?) memory leaks by removing the need for calls to retain, release, and autorelease as the compiler will handle inserting these calls for you. Apple even managed to get ARC backwards-compatible with iOS 4, so even if you&#8217;re not using any iOS 5 specific features, you may still want to make your next game with ARC.</p>
<p>The thing is, if you try to compile the Cocos2D files with ARC, you&#8217;ll be greeted by a nice big list of broke. So how do you get Cocos2D and ARC to play nicely together?</p>
<h3><span id="more-818"></span>No ARC for Cocos2D</h3>
<p>Unless you want to completely rewrite Cocos2D from the ground up to be ARC-compatible, you&#8217;re going to have to disable ARC for the Cocos2D source code. If you&#8217;re using one of the Cocos2D templates or have simply dragged the source code into your Xcode project, you&#8217;ll need to disable ARC for each of the .m Cocos2D source files by setting the compiler flags for each Cocos2D source file.</p>
<p>But there&#8217;s an easier way, and it uses something called cross-project references. For Cocos2D, this is actually quite simple to set up. In your Cocos2D source folder, you&#8217;ll find an Xcode project called <strong>cocos2d-ios.xcodeproj</strong>. Simply drag this into your Xcode project, and it&#8217;ll show up as a project <em>within</em> your project. You can then go into your project <strong>Build Phases</strong> settings and add the Cocos2D libs to the <strong>Link Binary With Libraries</strong> build phase.</p>
<p><a href="http://www.tinytimgames.com/wp-content/uploads/2011/07/Screen-Shot-2011-07-21-at-10.49.15-AM.png"><img class="aligncenter size-full wp-image-819" title="Cocos2D and ARC - Link Binary With Libraries" src="http://www.tinytimgames.com/wp-content/uploads/2011/07/Screen-Shot-2011-07-21-at-10.49.15-AM.png" alt="" width="596" height="440" /></a></p>
<p>After this, go to your project&#8217;s <strong>Build Settings</strong>, set <strong>Always Search User Paths</strong> to YES, and add your Cocos2D source directory to <strong>User Header Search Paths</strong>, and make sure it&#8217;s marked <strong>Recursive</strong>.</p>
<p><a href="http://www.tinytimgames.com/wp-content/uploads/2011/07/Screen-Shot-2011-07-21-at-12.29.18-PM.png"><img class="aligncenter size-full wp-image-820" title="Cocos2D and ARC - User Header Search Paths" src="http://www.tinytimgames.com/wp-content/uploads/2011/07/Screen-Shot-2011-07-21-at-12.29.18-PM.png" alt="" width="541" height="123" /></a></p>
<p>Now what was the benefit of doing all of this? Well, instead of going through all of the Cocos2D source files and disabling ARC compiling for each one of them, you can simply disable ARC compiling for just the Cocos2D project (and thus the Cocos2D static library it creates) and leave it enabled for the rest of your project. In fact, the Cocos2D project should already have ARC compiling disabled, so you&#8217;ll just need to make sure ARC is enabled for your parent project. (Note: While ARC itself isn&#8217;t under NDA as it&#8217;s <a title="ARC" href="http://clang.llvm.org/docs/AutomaticReferenceCounting.html" target="_blank">a part of LLVM</a>, the new Xcode which integrates ARC settings is, so you&#8217;ll have to figure out how to enable ARC for your project yourself. It&#8217;s pretty easy though, and you can always poke around the <a title="Apple Developer Forums" href="https://devforums.apple.com" target="_blank">Apple Developer Forums</a> to find what you&#8217;re looking for.)</p>
<h3>Some Cocos2D Modifications</h3>
<p>If you were to build your project as it is, you&#8217;ll notice that it still doesn&#8217;t compile, complaining about ARC stuff. What gives? I thought we turned off ARC compiling for Cocos2D? We did. The source files are not being compiled under ARC. What <em>is</em> being compiled under ARC is any <em>header files</em> you include in your ARC-compiled source files (i.e., <strong>cocos2d.h</strong>, and everything that <em>it</em> includes).</p>
<p>So what do we do? We&#8217;ll need to make some modifications to header files, but it&#8217;s only a few files. I&#8217;ve forked the main Cocos2D git repository and included these changes <a title="Cocos2D with ARC-compatible headers" href="https://github.com/jerrodputman/cocos2d-iphone" target="_blank">here</a>, so if you want you can just download that and use the Xcode project in it instead of making these modifications by hand. I&#8217;ll try to keep this repo integrated with new versions of Cocos2D.</p>
<p>First, open up <strong>CCDirectorIOS.h</strong>. Find the <strong>CCDirectorFast</strong> interface, and remove the <strong>NSAutoreleasePool</strong> ivar. Switch over to <strong>CCDirectorIOS.m</strong>, and add the following somewhere:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">static</span> <span style="color: #400080;">NSAutoreleasePool</span> <span style="color: #002200;">*</span>autoreleasePool <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;</pre></div></div>

<p>Then, open up <strong>CCActionManager.h</strong>. Near the top, you&#8217;ll see a struct called <strong>tHashElement</strong>. This struct references some Objective-C objects, which is a no-no in ARC. To get around this, you simply want to add some modifiers to tell the compiler that we know what we&#8217;re doing and to not worry:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">typedef</span> <span style="color: #a61390;">struct</span> _hashElement
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">struct</span> ccArray	<span style="color: #002200;">*</span>actions;
	__unsafe_unretained <span style="color: #a61390;">id</span>			target;
	NSUInteger		actionIndex;
	__unsafe_unretained CCAction		<span style="color: #002200;">*</span>currentAction;
	<span style="color: #a61390;">BOOL</span>			currentActionSalvaged;
	<span style="color: #a61390;">BOOL</span>			paused;
	UT_hash_handle	hh;
<span style="color: #002200;">&#125;</span> tHashElement;</pre></div></div>

<p>And finally, the biggest change of them all. If you go to <strong>ccCArray.h</strong>, you&#8217;ll notice a similar situation to above, a struct with a reference to an Objective-C object, which can be easily solved with <strong>__unsafe_unretained</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">typedef</span> <span style="color: #a61390;">struct</span> ccArray <span style="color: #002200;">&#123;</span>
	NSUInteger num, max;
	__unsafe_unretained <span style="color: #a61390;">id</span> <span style="color: #002200;">*</span>arr;
<span style="color: #002200;">&#125;</span> ccArray;</pre></div></div>

<p>But the bigger problem is the rest of the file. There&#8217;s a bunch of inline functions which do all sorts of un-ARC-able things. Unfortunately, the only real solution is to move the body of these functions into a new .m source file, and leave behind only the function prototypes in the header. For this, I strongly recommend just downloading the two files (<a title="ccCArray.h" href="https://github.com/jerrodputman/cocos2d-iphone/blob/develop/cocos2d/Support/ccCArray.h" target="_blank">here</a> and <a title="ccCArray.m" href="https://github.com/jerrodputman/cocos2d-iphone/blob/develop/cocos2d/Support/ccCArray.m" target="_blank">here</a>) directly from GitHub.</p>
<h3>Retain Knowledge, Not Objects</h3>
<p>After you&#8217;ve done these few modifications, you should be able to compile and bask in the glory that is ARC! Should you retain that CCSprite object? Who knows! You don&#8217;t have to worry about it anymore! You can create Cocos2D objects in your ARC code, and the compiler will handle all of the retain/release stuff for you. Meanwhile, the Cocos2D objects handle their own memory management internally. They both work together so that you can write your code faster and cleaner than before.</p>
<p>Note that you can also use this trick with other 3rd party libraries. As you might have noticed in the screens above, I have Objective-Chipmunk (an Objective-C version of the Chipmunk physics library) working with ARC as well, and it only required some minor changes in a single header file.</p>
<p>If you have any questions about this procedure, just post a comment below, and I&#8217;ll try to answer any questions to the best of my knowledge.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/07/22/cocos2d-and-arc/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>Diversion</title>
		<link>http://www.tinytimgames.com/2011/06/28/diversion/</link>
		<comments>http://www.tinytimgames.com/2011/06/28/diversion/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 19:13:38 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sheepstacker]]></category>
		<category><![CDATA[Software Updates]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=815</guid>
		<description><![CDATA[So I decided to take a little time off from developing Sol Defender for a while to get a few other &#8220;quick&#8221; projects finished. The first of these projects was a prototype that I&#8217;ve been wanting to do for some time. I think the prototype was a success, and we&#8217;ll be exploring a full version [...]]]></description>
			<content:encoded><![CDATA[<p>So I decided to take a little time off from developing Sol Defender for a while to get a few other &#8220;quick&#8221; projects finished. The first of these projects was a prototype that I&#8217;ve been wanting to do for some time. I think the prototype was a success, and we&#8217;ll be exploring a full version of it in the future. But at the moment, we have far too many half-finished projects to start yet another one.</p>
<p>The other project I wanted to pursue was updating our existing games. It&#8217;s been a long time since we&#8217;ve pushed out any updates, and our games seriously needed them. As you may have seen <a title="Sheepstacker 1.4 Now Available!" href="http://www.tinytimgames.com/2011/06/27/sheepstacker-1-4-now-available/">from our news section</a>, we managed to release an updated version of Sheepstacker. I&#8217;m going to go into a bit of what changed and what we had to do to get this update out the door.</p>
<h3><span id="more-815"></span>Embracing UIKit</h3>
<p>For both Sheepstacker and Word Monkey, we used a custom-built UI solution that used Unity&#8217;s built-in GUITexture and GUIText types. While I had gotten very good at manipulating it, it was still a pain to work with and not at all flexible. For version 1.4 of Sheepstacker, I decided to do something crazy and completely rewrite the UI (all of it) completely in UIKit.</p>
<p>The first step in this process was downloading and importing <a title="Prime31 Unity plugins" href="http://www.prime31.com/unity/" target="_blank">Prime31</a>&#8216;s excellent <a title="Prime31's NativeToolkit plugin" href="http://u3d.as/content/prime31-studios/native-toolkit-unity-to-i-os-bridge/1vj" target="_blank">NativeToolkit plugin</a>, which provided a simple interface for showing UIKit view controllers whenever necessary. I had to make some modifications to the Objective-C code, however, as I wanted to have a static background view that would stick around through navigation transitions (i.e., a &#8220;paused&#8221; image and dark background are always visible while the user is paused, even if he goes to the options screen).</p>
<p>Creating the screens in UIKit was a breeze, because I was able to use Interface Builder to lay everything out. Retina display support was handled automatically (I just had to supply an @2x version of each image). And the iPad UI was dead simple to implement as well, as I simply created separate XIBs and used the same classes to power them.</p>
<p>On the whole, I enjoyed the process, but it too much longer than I had anticipated it would. This mostly had to do with the fact that we already had a fully functional game set up in a particular way that was now having all of its UI rewritten. In fact, all of the old UI was removed. The only thing that remains is in the in-game HUD, as it would have been too much of a performance hit to have that handled in UIKit (would have to send the game state to native code each frame, which is a bit expensive to do).</p>
<h3>Game Center and the End of AGON</h3>
<p>Game Center was implemented through the use of another Prime31 plugin. For the most part, this process was straightforward, with the exception of having to serialize scores and achievements when there&#8217;s a network error.</p>
<p>My favorite new feature in the update is the display of your friends&#8217; high scores when you finish a game. I saw this feature implemented in Retro Dreamer&#8217;s excellent <a title="Velocispider" href="http://retrodreamer.com/velocispider.htm" target="_blank">Velocispider</a> and though to myself, &#8220;This needs to be in Sheepstacker!&#8221; It really motivates you to keep playing the game when you see that your friend has a higher score than you, instead of some random username.</p>
<p>Another reason for pushing out this update now is that the AGON Online leaderboards and achievements platform is scheduled to shutdown on June 30th. While the AGON team gave us plenty of time to do something about this, what they didn&#8217;t provide was an updated library that worked with the latest version of Unity and Xcode. Unfortunately, this meant that we were unable to save any of our users scores or unlocked achievements.</p>
<p>While I&#8217;m personally deeply regretful about this, the fact is that we actually did make a few significant gameplay changes that might have made resetting the leaderboards a necessity anyways.</p>
<h3>Gameplay Tweaks</h3>
<p>The fact that the sheep spew forth nickels when you combo stack is really just a joke between my wife and myself. I asked what should spew out when a combo started (thinking of sparkles or something), and my wife said plainly, &#8220;Nickels.&#8221; And that was the end of that.</p>
<p>What I didn&#8217;t do a good job of was incorporating the nickels into the actual gameplay. The nickels were originally supposed to be another score type, as it was more indicative of how well you stacked instead of how high you stacked. However, most players were simply confused by their presence and referred to their stack height as their score. Even I did this.</p>
<p>In the new version, I wanted to make the nickels actually important to gameplay. We&#8217;d had this odd game rule where the user would get an extra heart every 50 sheep stacked (plus one at 25). In 1.4, that rule has been removed and extra hearts are now earned with every 250 nickels. This means that a player&#8217;s stack quality directly affects how high he can stack, because the better his stack, the more nickels he has, which means more hearts, which means more chances to keep stacking. I&#8217;m a bit irritated that I didn&#8217;t come up with the idea two years ago when we first released the game as it seems so obvious now. Nickels also add extra time to Speed Stack, again directly affecting gameplay.</p>
<p>The other tweak we made was reducing the maximum heart count from four to three. We had three hearts initially when we were developing the game, but felt that the game was too hard for newer players. After seeing more players play the game, I came to realize that the extra heart didn&#8217;t actually help that much. In fact, it seemed to have the opposite effect as players wouldn&#8217;t play as carefully as they did when there were only three hearts. The change just &#8220;feels&#8221; right. That&#8217;s really all there is to it.</p>
<h3>Now What?</h3>
<p>So Sheepstacker 1.4 is out, and I hope everyone is enjoying it. Unless necessary, the game probably won&#8217;t see another update until iOS 5 releases later this year (as we want to update the game to take advantage of some of the new Game Center features).</p>
<p>But what&#8217;s next? Back to Sol Defender? Not quite yet. We have an opportunity to be on the leading edge of iOS gaming. It&#8217;s an interesting opportunity, and it may not pan out, but we&#8217;ve got to try it. After we&#8217;re finished with that, I&#8217;ll be returning to Sol Defender, as it&#8217;s a game I&#8217;ve been wanting to make since the App Store launched.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/06/28/diversion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Music Notes</title>
		<link>http://www.tinytimgames.com/2011/05/15/music-notes/</link>
		<comments>http://www.tinytimgames.com/2011/05/15/music-notes/#comments</comments>
		<pubDate>Sun, 15 May 2011 21:32:17 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Sol Defender]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=798</guid>
		<description><![CDATA[I essentially grew up listening to video game music. From the 3-second stingers in Pitfall, to the iconic Super Mario Bros. theme, to anything and everything by Nobuo Uematsu, to say that game music is my primary &#8220;genre&#8221; of choice would not be inaccurate. Oh sure, I learned to play the drums by watching Bon [...]]]></description>
			<content:encoded><![CDATA[<p>I essentially grew up listening to video game music. From the 3-second stingers in Pitfall, to the iconic Super Mario Bros. theme, to anything and everything by Nobuo Uematsu, to say that game music is my primary &#8220;genre&#8221; of choice would not be inaccurate. Oh sure, I learned to play the drums by watching Bon Jovi videos, and there were those odd high school years where I listened to whatever the kids were into those days, but game music is what I love.</p>
<p>I&#8217;m sad to say that in all my years, I&#8217;ve never tried to sit down and learn to play or write music. I knew I wanted to make my own games, but I just assumed someone else would write the music. After all, they have the talent&#8230; whoever &#8220;they&#8221; are. But I&#8217;ve been studying music for a long time. I enjoy the music I listen to, but oftentimes I&#8217;ll just sit, listen, and study the reason why a particular piece of music makes me feel the way I&#8217;m feeling.</p>
<p>Cut to January 2010. Shannon and I are working feverishly on Word Monkey, trying to tie up all the loose ends before sending it to the gatekeepers at Apple. One of the last things on the list is to find some music. I had assumed we would just license some music online, but after many days of searching, I just hadn&#8217;t found what I was looking for.</p>
<p>Then Shannon, wonderful wife that she is, decided she&#8217;d take a stab at making something in GarageBand.</p>
<h3><span id="more-798"></span>The Gateway Drug</h3>
<p>As I watched Shannon play around in GarageBand, I was impressed by what she was able to create with very little effort using the built-in Apple loops. After hearing a few things she had created, I decided I&#8217;d like to play around in GarageBand for a bit as well. I was bleary-eyed and worn out from UI coding marathons, so a bit of experimentation sounded like fun.</p>
<p>After a day of playing around (and a few tweaks thereafter), here is the main gameplay track you hear in Word Monkey today:</p>
<script type='text/javascript'>_wpaudio.enc['wpaudio-4f2ef5dd0a163'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0074\u0069\u006e\u0079\u0074\u0069\u006d\u0067\u0061\u006d\u0065\u0073\u002e\u0063\u006f\u006d\u002f\u0077\u0070\u002d\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002f\u0075\u0070\u006c\u006f\u0061\u0064\u0073\u002f\u0032\u0030\u0031\u0031\u002f\u0030\u0035\u002f\u0044\u0061\u006e\u0063\u0065\u002d\u0044\u0061\u006e\u0063\u0065\u002d\u004d\u006f\u006e\u006b\u0065\u0079\u002e\u006d\u0070\u0033';</script><a id='wpaudio-4f2ef5dd0a163' class='wpaudio wpaudio-nodl wpaudio-enc' href='#'>Dance Dance Monkey</a>
<p>&nbsp;</p>
<p>Granted, it&#8217;s all made from some edited and filtered Apple loops, but I was pleased with what we had created. It was new; it was created specifically for our game; and most importantly, it was what I was looking for!</p>
<p>From then on, I started studying music more seriously. I ran through the lessons included with GarageBand. I bought myself a MIDI keyboard from the local Apple Store. I remember the checkout clerk asking if I wrote music. I answered, &#8220;Not yet!&#8221; Unfortunately, it wouldn&#8217;t be until December that I would actually sit down and try to actually write anything substantial.</p>
<h3>Sol Defender</h3>
<p>I started what I would call &#8220;work&#8221; on Sol Defender in November 2010, and as I mentioned in a previous post got sidetracked by the Visualize plugin and holidays and such. But in December, I started to get the itch to write a little bit of music for the game.</p>
<p>I knew the style I was going for. I&#8217;m a big fan of <a title="David Bergeaud's site" href="http://www.musipolis.com" target="_blank">David Bergeaud</a>&#8216;s work for the Ratchet &amp; Clank series (a benefit of working at Insomniac was that I had direct access to the uncompressed music files) which tends to emphasize harsh brass (think Michael Giacchino&#8217;s work on the TV show Lost) with some drum loops to keep the pace with the on-screen action. I remember the first time the music was placed into the Kavu Island level of Ratchet &amp; Clank: Up Your Arsenal and how it magnified the intensity of the battle tenfold. That was the effect I wanted to achieve with Sol Defender&#8217;s music.</p>
<p>So I grabbed the Orchestral Jam Pack for GarageBand and, being that drums are the instrument I <em>actually</em> know how to play, I started with a simple pounding beat.</p>
<script type='text/javascript'>_wpaudio.enc['wpaudio-4f2ef5dd0b110'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0074\u0069\u006e\u0079\u0074\u0069\u006d\u0067\u0061\u006d\u0065\u0073\u002e\u0063\u006f\u006d\u002f\u0077\u0070\u002d\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002f\u0075\u0070\u006c\u006f\u0061\u0064\u0073\u002f\u0032\u0030\u0031\u0031\u002f\u0030\u0035\u002f\u0046\u0069\u006e\u0061\u006c\u002d\u0048\u006f\u0075\u0072\u002d\u0043\u006f\u006e\u0073\u0074\u0072\u0075\u0063\u0074\u0069\u006f\u006e\u002d\u0031\u002e\u006d\u0070\u0033';</script><a id='wpaudio-4f2ef5dd0b110' class='wpaudio wpaudio-nodl wpaudio-enc' href='#'>Orchestra Percussion Beat</a>
<p>&nbsp;</p>
<p>From there, I added brass to the beat, with a little French horn crescendo to liven up the dead space between.</p>
<script type='text/javascript'>_wpaudio.enc['wpaudio-4f2ef5dd0c0a0'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0074\u0069\u006e\u0079\u0074\u0069\u006d\u0067\u0061\u006d\u0065\u0073\u002e\u0063\u006f\u006d\u002f\u0077\u0070\u002d\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002f\u0075\u0070\u006c\u006f\u0061\u0064\u0073\u002f\u0032\u0030\u0031\u0031\u002f\u0030\u0035\u002f\u0046\u0069\u006e\u0061\u006c\u002d\u0048\u006f\u0075\u0072\u002d\u0043\u006f\u006e\u0073\u0074\u0072\u0075\u0063\u0074\u0069\u006f\u006e\u002d\u0032\u002e\u006d\u0070\u0033';</script><a id='wpaudio-4f2ef5dd0c0a0' class='wpaudio wpaudio-nodl wpaudio-enc' href='#'>Brass Additions</a>
<p>&nbsp;</p>
<p>With just that, I was already pretty excited by what I had. It was actually starting to sound like something! Not much, but something! I added two drum loops after the eighth measure and threw in a little timpani transition to kick it off. And then&#8230; hmmm&#8230; there was a lot of blank space left to fill.</p>
<p>I still didn&#8217;t really know a lot of the fundamentals to music, so I just started playing some chords with the brass ensemble instrument. Hey, not bad! I kept going, and before long I had sixteen measures, and it even looped nicely!</p>
<script type='text/javascript'>_wpaudio.enc['wpaudio-4f2ef5dd0d049'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0074\u0069\u006e\u0079\u0074\u0069\u006d\u0067\u0061\u006d\u0065\u0073\u002e\u0063\u006f\u006d\u002f\u0077\u0070\u002d\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002f\u0075\u0070\u006c\u006f\u0061\u0064\u0073\u002f\u0032\u0030\u0031\u0031\u002f\u0030\u0035\u002f\u0046\u0069\u006e\u0061\u006c\u002d\u0048\u006f\u0075\u0072\u002d\u0043\u006f\u006e\u0073\u0074\u0072\u0075\u0063\u0074\u0069\u006f\u006e\u002d\u0033\u002e\u006d\u0070\u0033';</script><a id='wpaudio-4f2ef5dd0d049' class='wpaudio wpaudio-nodl wpaudio-enc' href='#'>Intro + Chorus</a>
<p>&nbsp;</p>
<p>I had actually thought about stopping there, but then I had a thought for a small cool-down section after the brass &#8220;chorus&#8221;. So I loaded up the string staccato instrument, and went to work:</p>
<script type='text/javascript'>_wpaudio.enc['wpaudio-4f2ef5dd0ef8d'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0074\u0069\u006e\u0079\u0074\u0069\u006d\u0067\u0061\u006d\u0065\u0073\u002e\u0063\u006f\u006d\u002f\u0077\u0070\u002d\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002f\u0075\u0070\u006c\u006f\u0061\u0064\u0073\u002f\u0032\u0030\u0031\u0031\u002f\u0030\u0035\u002f\u0046\u0069\u006e\u0061\u006c\u002d\u0048\u006f\u0075\u0072\u002d\u0043\u006f\u006e\u0073\u0074\u0072\u0075\u0063\u0074\u0069\u006f\u006e\u002d\u0034\u002e\u006d\u0070\u0033';</script><a id='wpaudio-4f2ef5dd0ef8d' class='wpaudio wpaudio-nodl wpaudio-enc' href='#'>String Cool Down</a>
<p>&nbsp;</p>
<p>At that point, I had the essentials to the very first track for Sol Defender. After a lot (a lot) of additional iteration, I now present the (hopefully) final version of &#8220;Final Hour&#8221;:</p>
<script type='text/javascript'>_wpaudio.enc['wpaudio-4f2ef5dd0ff2d'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0074\u0069\u006e\u0079\u0074\u0069\u006d\u0067\u0061\u006d\u0065\u0073\u002e\u0063\u006f\u006d\u002f\u0077\u0070\u002d\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002f\u0075\u0070\u006c\u006f\u0061\u0064\u0073\u002f\u0032\u0030\u0031\u0031\u002f\u0030\u0035\u002f\u0046\u0069\u006e\u0061\u006c\u002d\u0048\u006f\u0075\u0072\u002e\u006d\u0070\u0033';</script><a id='wpaudio-4f2ef5dd0ff2d' class='wpaudio wpaudio-nodl wpaudio-enc' href='#'>Final Hour</a>
<p>&nbsp;</p>
<p>And here&#8217;s what the GarageBand window for this song looks like:</p>
<div id="attachment_799" class="wp-caption aligncenter" style="width: 591px"><a href="http://www.tinytimgames.com/wp-content/uploads/2011/05/Screen-shot-2011-05-07-at-10.23.05-PM.png"><img class="size-full wp-image-799   " title="Sol Defender 1 GarageBand Window" src="http://www.tinytimgames.com/wp-content/uploads/2011/05/Screen-shot-2011-05-07-at-10.23.05-PM.png" alt="" width="581" height="341" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<h3>Something In Between</h3>
<p>Here&#8217;s another track I&#8217;m working on for the game, which will go in the level selection screen, so it&#8217;s a pretty short loop. A bit of backstory: I remember the first time I heard <a title="Dream of the Shore - Chrono Cross - Yasunori Mitsuda" href="http://youtu.be/MV-FvxoR1PQ" target="_blank">Dream of the Shore</a> from Chrono Cross after Serge crossed over into Another World where no one recognized him, even the girl who had just finished saying they would never forget that day (at least in my playthrough). It&#8217;s that sort of mood that I wanted to capture with this track. The first time you see this screen is after a pretty big story event during the prologue, and I wanted the music to reflect the mood of the story after that point.</p>
<script type='text/javascript'>_wpaudio.enc['wpaudio-4f2ef5dd11e71'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0077\u0077\u0077\u002e\u0074\u0069\u006e\u0079\u0074\u0069\u006d\u0067\u0061\u006d\u0065\u0073\u002e\u0063\u006f\u006d\u002f\u0077\u0070\u002d\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002f\u0075\u0070\u006c\u006f\u0061\u0064\u0073\u002f\u0032\u0030\u0031\u0031\u002f\u0030\u0035\u002f\u004c\u0065\u0076\u0065\u006c\u002d\u0053\u0065\u006c\u0065\u0063\u0074\u002e\u006d\u0070\u0033';</script><a id='wpaudio-4f2ef5dd11e71' class='wpaudio wpaudio-nodl wpaudio-enc' href='#'>Level Select (First Draft)</a>
<p>&nbsp;</p>
<p>I don&#8217;t think I&#8217;m quite finished with it yet. The problem is that anything I add to it seems to subtract more than add, so it may stay as it is.</p>
<h3>More Tracks And Feedback</h3>
<p>There are still a few more tracks I&#8217;d like to write for the game, like boss battle music and such. I may not have time (or talent) to create a new piece of music for each level, so I&#8217;m going to settle on a few moods that will be seen throughout the game and focus on those.</p>
<p>And of course, I welcome any feedback, especially from other musicians. You can be brutally honest too, just as long as it&#8217;s constructive and I learn something from it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/05/15/music-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://www.tinytimgames.com/wp-content/uploads/2011/05/Dance-Dance-Monkey.mp3" length="2328368" type="audio/mpeg" />
<enclosure url="http://www.tinytimgames.com/wp-content/uploads/2011/05/Final-Hour-Construction-1.mp3" length="217674" type="audio/mpeg" />
<enclosure url="http://www.tinytimgames.com/wp-content/uploads/2011/05/Final-Hour-Construction-2.mp3" length="224361" type="audio/mpeg" />
<enclosure url="http://www.tinytimgames.com/wp-content/uploads/2011/05/Final-Hour-Construction-3.mp3" length="882647" type="audio/mpeg" />
<enclosure url="http://www.tinytimgames.com/wp-content/uploads/2011/05/Final-Hour-Construction-4.mp3" length="114856" type="audio/mpeg" />
<enclosure url="http://www.tinytimgames.com/wp-content/uploads/2011/05/Final-Hour.mp3" length="2439545" type="audio/mpeg" />
<enclosure url="http://www.tinytimgames.com/wp-content/uploads/2011/05/Level-Select.mp3" length="2078846" type="audio/mpeg" />
		</item>
		<item>
		<title>Mod Squad</title>
		<link>http://www.tinytimgames.com/2011/05/10/mod-squad/</link>
		<comments>http://www.tinytimgames.com/2011/05/10/mod-squad/#comments</comments>
		<pubDate>Tue, 10 May 2011 15:52:35 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sol Defender]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=794</guid>
		<description><![CDATA[Here&#8217;s a feature I&#8217;m pretty excited about: the mod system. Now, mod systems are nothing new. We tried to implement one for Ratchet: Deadlocked. In fact, my buddy Nathan Fouts over at Mommy&#8217;s Best Games is implementing somewhat of a mod system for Serious Sam: Double D. They come in all sorts of varieties, but [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a feature I&#8217;m pretty excited about: the mod system. Now, mod systems are nothing new. We tried to implement one for Ratchet: Deadlocked. In fact, my buddy Nathan Fouts over at <a title="Mommy's Best Games" href="http://www.mommysbestgames.com" target="_blank">Mommy&#8217;s Best Games</a> is implementing somewhat of a mod system for <a title="Serious Sam: Double D" href="http://mommysbest.blogspot.com/2011/03/serious-sam-double-d.html" target="_blank">Serious Sam: Double D</a>. They come in all sorts of varieties, but I wanted to boil the idea of a mod system down to its purest form.</p>
<p>As it is currently prototyped, the mod system for (still tentatively titled) Sol Defender works like this: The player&#8217;s ship has a singular source of energy that powers all of its critical systems. This includes weapons, propulsion, shields, and even the item pick-up radius around the ship. As the player &#8220;levels up&#8221; his ship over the course of the game, more of this energy will be unlocked. The player can then equip mods to funnel this energy into any of the aforementioned systems in any manner he desires.</p>
<p>That&#8217;s the gist of the mod system, but to put it into more practical and tangible terms, I&#8217;ll go into a few examples.</p>
<h3><span id="more-794"></span>Weapon Overload</h3>
<p>Let&#8217;s talk about weapons first, since that&#8217;s easier to think about and show visually. Let&#8217;s say the player starts out with the standard slow-firing, slow-moving, short-lived pea-shot. He has leveled up and unlocked one &#8220;mod slot&#8221; in which he can equip a mod. Mods are purchased from an in-game store with in-game currency (don&#8217;t worry; no IAP mods).</p>
<p>If the player purchases and equips a Rapid Shot mod, his rate of fire will increase. If he equips a Split Shot mod, the shots will emit from the ship in a V-shape, effectively giving the player dual cannons. With only one mod slot, the player will have to choose which of these is more important to him at this point.</p>
<p>But fast forward to later in the game, when the player has the potential to have ten mod slots available. What would happen if he equipped ten Rapid Shot mods all at once? What about ten Split Shot mods? All mods in the game stack on top of each other with each mod&#8217;s effects being cumulative. Ten Rapid Shot mods would create almost a constant stream of bullets. Ten Split Shot mods creates this glorious image below:</p>
<div id="attachment_796" class="wp-caption aligncenter" style="width: 556px"><a href="http://www.tinytimgames.com/wp-content/uploads/2011/05/Screenshot0026.png"><img class="size-full wp-image-796  " title="10 Split Mods" src="http://www.tinytimgames.com/wp-content/uploads/2011/05/Screenshot0026.png" alt="" width="546" height="364" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>Naturally, putting ten of any mod on your ship will put you at a disadvantage in other areas, but it leaves the control in the player&#8217;s hands, which is usually a good thing.</p>
<p>The video below shows one possible combination. Three Rapid Shot mods, four Split Shot mods, two Reverse Shot mods (which fires shots in the reverse direction), and one Reflect Shot mod (which causes bullets to bounce off of enemies on impact) will create something that looks a bit like this:</p>
<p><object width="600" height="363"><param name="movie" value="http://www.youtube.com/v/Q9Jzd9mOPg8?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Q9Jzd9mOPg8?version=3" type="application/x-shockwave-flash" width="600" height="363" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h3>Shields Up (And Other Stuff)</h3>
<h3><span style="font-weight: normal; font-size: 13px;">So that&#8217;s how the mod system will work for weapons. But as I mentioned, the mods tap into the ship&#8217;s singular energy source to power a variety of different upgrades. There will also be mods that increase the strength or recharge rate of the player&#8217;s shields, mods that make the ship move faster, and even mods that multiply the experience points the player receives. </span><span style="font-weight: normal; font-size: 13px;">Essentially, the mod system controls everything about the player&#8217;s ship, which means that the player is completely in control of how they want to progress in the game.</span></h3>
<p><span style="font-weight: normal; font-size: 13px;">We&#8217;ll also be designing levels that are easier to complete when certain mods are favored over other ones. Imagine a fire planet with enemies engulfed in flames. The player might decide to stock up on Freeze Shot mods to cool the enemies down, or spend their mod allotment on shield upgrades to counteract the blistering heat of the environment.</span></p>
<h3>More Work</h3>
<p>While the implementation of the mods themselves is pretty straightforward, there&#8217;s a lot of side work that needs to be done for the whole package to come together nicely. There&#8217;s the interface for equipping and unequipping mods, the storefront for buying the mods themselves, and the ongoing process of balancing the mods over the course of the game.</p>
<p>I&#8217;ll write up another update on the mod system as it progresses. However, the next post is going to be about something I&#8217;m both very nervous and extremely excited about. I&#8217;ve taken it upon myself to write all of the music for the game! And I&#8217;m going to share a bit of what I have so far along with the process of how I made it. So stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/05/10/mod-squad/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Shockwave</title>
		<link>http://www.tinytimgames.com/2011/04/24/shockwave/</link>
		<comments>http://www.tinytimgames.com/2011/04/24/shockwave/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 06:50:01 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sol Defender]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=791</guid>
		<description><![CDATA[First of all, I&#8217;ve settled on a name for the game that has so far been called &#8220;Sol Defender&#8221;. You&#8217;ll hear more about that later for the official unveiling. Since my last post, a lot of work has been done in a variety of areas, but I&#8217;m only going to focus on one for this [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, I&#8217;ve settled on a name for the game that has so far been called &#8220;Sol Defender&#8221;. You&#8217;ll hear more about that later for the official unveiling.</p>
<p>Since my last post, a lot of work has been done in a variety of areas, but I&#8217;m only going to focus on one for this post: the Shockbomber! If you&#8217;ve played Geometry Wars, then you know that sometimes you can just get overwhelmed by the massive amounts of enemies on screen, and sometimes you just need some help. The Shockbomber essentially fills that &#8220;screen killing&#8221; role, with a bit of a spherical world twist.</p>
<h3><span id="more-791"></span>The Visuals</h3>
<p>As mentioned earlier, the idea for the Shockbomber is to clear out a screen-full of enemies. Now the easiest way to do this would just be to flash the screen white and destroy all of the enemies on screen. But as the game takes place on a spherical world, I figured I could do something a little more interesting visually.</p>
<p><object width="600" height="363"><param name="movie" value="http://www.youtube.com/v/d2k2aPYNq7Y?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/d2k2aPYNq7Y?version=3" type="application/x-shockwave-flash" width="600" height="363" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>As you can see from the above video, the Shockbomber emits a shockwave spreading outwards from the player destroying anything in its path. You&#8217;ll notice that the shockwave actually wraps around the surface of the planet, creating a pretty cool visual effect. One bonus of creating the bomb like this is that it opens the door for enemies to &#8220;jump&#8221; over the shockwave! I probably won&#8217;t use this on standard enemies since the whole point of using the bomb is when you get overwhelmed. But it might be nice during a boss battle or something. Or hey, maybe I should add a jump button to the player&#8230; !</p>
<h3>The Code</h3>
<p>To get the ring around the planet effect, I used Unity&#8217;s Line Renderer component and set the vertex count and line width to something reasonable. The vertex positions are what give the ring its shape, so I needed a method that not only programmatically created a ring, but make the ring expand and wrap around a spherical body as it moved along its surface.</p>
<p>I decided to leverage what I already had with the bullets, whose movement code boils down to simply this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">sphericalMovement.<span style="color: #660066;">Move</span><span style="color: #009900;">&#40;</span>transform.<span style="color: #000066;">forward</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I&#8217;ve moved all <a title="Spherical" href="http://www.tinytimgames.com/2011/03/20/spherical/">spherical movement code</a> into its own script so I can simply added it as a component to anything that needs to move along a planet&#8217;s surface. Movement is then just a function call away.</p>
<p>So how do I use this to make a ring? Since bullets already move along the surface of the planet, what I needed to do was essentially fire a bullet that then emanated a ring from its position. To create the ring, I need an axis around which to create the ring:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> OnSpawn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   axis <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>sphericalMovement.<span style="color: #660066;">GravityDirection</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>GravityDirection is a property in the SphericalMovement component script, which essentially just gives the direction of gravity on the object. Taking the negative of this gives us the vector we&#8217;re looking for. OnSpawn is called after the projectile is spawned.</p>
<p>I now have everything I need to create the ring using a Line Renderer:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> Update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   sphericalMovement.<span style="color: #660066;">Move</span><span style="color: #009900;">&#40;</span>transform.<span style="color: #000066;">forward</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> kRingVertexCount<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> vertexPosition <span style="color: #339933;">=</span> Quaternion.<span style="color: #660066;">AxisAngle</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>360.0f <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span>kRingVertexCount <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> axis<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> transform.<span style="color: #660066;">position</span><span style="color: #339933;">;</span>
      lineRenderer.<span style="color: #660066;">SetPosition</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> vertexPosition<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And that&#8217;s really all there is to it. Collision detection is handled by doing Physics.RaycastAll() between each vertex in the line, get a list of hit GameObjects, and then calling damage functions on their appropriate components.</p>
<h3>New Language</h3>
<p>You may have noticed that this code was written in JavaScript instead of C# like my previous posts. I actually converted all of the scripts for the game to JavaScript over the weekend. While this may seem a bit insane, it was actually done for efficiency reasons.</p>
<p>I&#8217;m a bit OCD when it comes to object encapsulation and keeping everything properly private/protected/public, and C# simply gave me too much control over that. With JavaScript, most of that control is taken away from me, and I can get back to writing the game, not worrying about organization. Additionally, JavaScript is not nearly as verbose as C#, so I save some typing time too. There are a few things I can&#8217;t do in JavaScript, but I simply write those scripts in C# and place them in the Plugins folder (so they are compiled earlier, and thus exposed to JavaScript).</p>
<p>As a result, my scripts have become smaller and easier to read. Performance also hasn&#8217;t suffered since JavaScript and C# perform the same in Unity. Would I recommend this exercise to everyone that&#8217;s using C#? No. It&#8217;s purely for personal efficiency reasons, but I would recommend dipping your toe into Unity&#8217;s JavaScript from time to time as they improve the language quite a bit from version to version.</p>
<p>That&#8217;s all for now. Next post will be focusing on a very cool system I&#8217;ve been prototyping for this game&#8230; the Mod system! I&#8217;m pretty excited about this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2011/04/24/shockwave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

