<?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>Snowferno &#187; How-To</title>
	<atom:link href="http://www.snowferno.com/category/blog/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.snowferno.com</link>
	<description>Do you have a snowball's chance?</description>
	<lastBuildDate>Mon, 26 Oct 2009 23:01:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Indie Game Marketing for Developers</title>
		<link>http://www.snowferno.com/2009/10/07/indie-game-marketing-for-developers/</link>
		<comments>http://www.snowferno.com/2009/10/07/indie-game-marketing-for-developers/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 00:43:05 +0000</pubDate>
		<dc:creator>benbritten</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[How-To]]></category>

		<guid isPermaLink="false">http://www.snowferno.com/?p=110</guid>
		<description><![CDATA[Last week I attended the Digital Distribution Summit here in Melbourne with fellow Escape Factory collaborator John.  Even though the name makes you think it would be terribly boring, (it probably should have been called the Digital Games Distribution Summit, bit I digress) it was actually very good.  
You can watch all of [...]]]></description>
			<content:encoded><![CDATA[<img alt='' src='http://www.gravatar.com/avatar/a1e8752136bc8045c465c739439460b2?s=96&amp;d=wavatar&amp;r=G' class='avatar avatar-96 photo' height='96' width='96' /><p>Last week I attended the <a href="http://ddsummit.com/">Digital Distribution Summit</a> here in Melbourne with fellow <a href="http://escfactory.com">Escape Factory</a> collaborator John.  Even though the name makes you think it would be terribly boring, (it probably should have been called the Digital Games Distribution Summit, bit I digress) it was actually very good.  </p>
<p>You can watch all of the speakers on the <a href="http://ddsummit.com/">DDSummit site</a>, which you should go and do now, and not bother reading this silly post.</p>
<p>If you are still reading, I will give you my belated thoughts on the content provided in the summit.  If you did not attend or have no idea what I am talking about then here is the very brief overview:</p>
<p>The DDSummit was geared towards indie level game developers who are looking to take advantage of the increasingly popular and available digital distribution methods (like XBLA, PSX, WiiWare, AppStore etc..)  The talks ranged all over but ultimately were there to help the little guy (thats us!) succeed in this new marketplace.  There is a smaller barrier to entry to the indie game market now than any other time in history.  </p>
<p>So that is the overview, what are some of the specifics?</p>
<p>Since I am an iPhone developer (so far) I mostly tried to apply everything that was being said to my situation (which is: zero budget development for iPhone).</p>
<p>The biggest thing that I took away from this event was that marketing is the single most important thing you can be doing right now.  (cynically, I might even say that it is more important than having a good game)  This is of course not really news to me, but having it laid out so many times and so clearly, it really hit home the fact that we are not marketing our stuff enough.  This is a common problem with the indies, we are all very good at what we do (which might be programming, artwork, game design, sound, etc..) but we are not really very good at marketing (otherwise we would be professional marketing types right?)</p>
<p>The presenters made many good points re: marketing.  If you make the best game ever and nobody knows about it, then nobody will buy it.  </p>
<p>That begs the question:  How do we, as indie developers who suck at marketing.... how do we get the word out?</p>
<p>This is a summary, in no particular order of the hints, suggestions and tips to better marketing. Some of these are directly from the talks and others are things that I synthesized from my notes.</p>
<ul>
<li><strong>Start your marketing on day one.</strong>  Do not build a protorype, do not write a design document, do not brainstorm game mechanics.  The very first thing you need to do is start the marketing process.  Write a blog post, tweet, whatever.  Then start the actual development.  Well, ok that might be a bit hyperbolic, but marketing needs to be in your plan from the very start.</li>
<li><strong>Marketing should be part of your dev process.</strong> Just like everything else you are doing to build your game.  Add marketing tasks into the flow.  Blog about what you are doing, tweet your advances and your challenges, solicit gamer feedback from your early design ideas</li>
<li><strong>Define your target audience.</strong> Figure out who is going to care about this game you are making.  Define a narrow group of people (dont say: this game is for everyone! because it isn't.) focus on a realistic group and cater your marketing to that group.</li>
<li><strong>Define your brand.</strong> As indies this tends to get lost.  Also often the brand become synonymous with the first successful game you develop.  As indies, our brand is our individual style and story.  Half of selling your games and ideas as an indie is having a compelling story.  By story I mean who you are and what it is you do. </li>
<li><strong>Twitter.</strong> I think I heard the word twitter or tweet about 900 times.  Twitter is the current social networking fad, and you should be using it.  Twitter is a multiplier for word of mouth.  Similarly, you should be abusing your facebook friends and using all those digital contacts to help push your game.  </li>
<li><strong>Blog.</strong> You should have some sort of web site/blog for your game or development studio.  (like this one! hello!)  Try to keep your blog fairly up to date with current topical posts that people will hopefully find interesting.  This will help keep your name and game in the tops of people's minds.</li>
<li><strong>Make good gameplay videos.</strong> Sometime after day 1, when you already started your marketing and everyone is anticipating your game release, you will need to make a good gameplay video.  Again, tailor this to your target audience. Be sure to show some actual gameplay though.  There is nothing more annoying than a game trailer that has no actual game footage.</li>
<li><strong>Enter every festival and contest you can.</strong> Do you qualify for the entry requirements? then enter it.  Even if you don't get in, or don't win you will generally get some exposure and some good game player feedback.</li>
<li><strong>Engage the community</strong> Go and be active in the forums and the blogs that are specific to your target audience.  Be a part of the gamer community.  Give back via your blog. Post how-tos and code snippets. </li>
</ul>
<p>That is a pretty good list to start.  </p>
<p>Trust me when I tell you that I sympathize with all the indies out there who are already busy just trying to build their games, let alone do all that other stuff.  It took me a week just to write this post because I was too busy with other projects.  However, in order to be a successful game developer you need to also be a successful marketer.  </p>
<p>Cheers!<br />
-B</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snowferno.com/2009/10/07/indie-game-marketing-for-developers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Tips for Levels 1 thru 3</title>
		<link>http://www.snowferno.com/2009/09/28/tips-for-levels-1-thru-3/</link>
		<comments>http://www.snowferno.com/2009/09/28/tips-for-levels-1-thru-3/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 20:17:05 +0000</pubDate>
		<dc:creator>balord</dc:creator>
				<category><![CDATA[How-To]]></category>

		<guid isPermaLink="false">http://www.snowferno.com/?p=108</guid>
		<description><![CDATA[Watch for our upcoming in-game fan community launching soon -- powered by playhaven.com.
Level 1: The Dark Wood
This is the standard "teaching" first level.  All you need to do is figure out how to roll forward and turn just a bit to get into the exit.
Level 2: Little Jump
Here we have our first challenge.  [...]]]></description>
			<content:encoded><![CDATA[<img alt='' src='http://www.gravatar.com/avatar/ca32281f6b82e611c51ccf7a6863c53b?s=96&amp;d=wavatar&amp;r=G' class='avatar avatar-96 photo' height='96' width='96' /><div class="notice" style="margin-right:130px;font-weight:bold;">Watch for our upcoming in-game fan community launching soon -- powered by <a href="http://www.playhaven.com/platforms/iphone/games/snowferno/">playhaven.com</a>.</div>
<p><strong>Level 1: The Dark Wood</strong><br />
This is the standard "teaching" first level.  All you need to do is figure out how to roll forward and turn just a bit to get into the exit.</p>
<p><strong>Level 2: Little Jump</strong><br />
Here we have our first challenge.  You are too small to get across the gap to the exit, so find some snow to get bigger.  But dont take too long -- summer is coming and you'll melt!</p>
<p><strong>Level 3: Switches</strong><br />
Here we see our first of many interactive items you'll encounter in the Inferno: switches.  There are two on this level -- one on the floor that drops your platform down to the lower level, and another that lowers the drawbridge so you can cross to the finish.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snowferno.com/2009/09/28/tips-for-levels-1-thru-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playhaven, Unity and Snowferno</title>
		<link>http://www.snowferno.com/2009/09/23/playhaven-unity-and-snowferno/</link>
		<comments>http://www.snowferno.com/2009/09/23/playhaven-unity-and-snowferno/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 01:47:42 +0000</pubDate>
		<dc:creator>benbritten</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[How-To]]></category>

		<guid isPermaLink="false">http://www.snowferno.com/?p=104</guid>
		<description><![CDATA[There is a new player in the iPhone-support website game: PlayHaven.  They are similar to Openfeint and Agon in that they provide some 3rd-party support for your game.  Unlike OF and Agon, Playhaven does not provide leaderboards and that sort of thing, instead they are trying to build a gaming community around guides, [...]]]></description>
			<content:encoded><![CDATA[<img alt='' src='http://www.gravatar.com/avatar/a1e8752136bc8045c465c739439460b2?s=96&amp;d=wavatar&amp;r=G' class='avatar avatar-96 photo' height='96' width='96' /><p>There is a new player in the iPhone-support website game: <a href="http://www.playhaven.com/">PlayHaven</a>.  They are similar to Openfeint and Agon in that they provide some 3rd-party support for your game.  Unlike OF and Agon, Playhaven does not provide leaderboards and that sort of thing, instead they are trying to build a gaming community around guides, hints, and forums.</p>
<p>In any case, back in the early days of the iPhone game development (like half a year ago) there were far fewer choices for adding leaderboard/achievement support to your app via 3rd party.  So after looking at the early OF and others and not being very happy with what they offered (at the time) we decided to go ahead and build our own leaderboards.</p>
<p>So, why playhaven then?</p>
<p>Well, ultimately it comes down to them emailing me and asking me to try it out.  We dont currently have any of the features they offer, so the fit seemed good.  Also, one nice thing about playhaven is that they are basing their entire 'api' (if you could call it that) around the UIWebView.  In other words there is no actual SDK to add to your code, you just whip open an in-app web view and there is the community.</p>
<p>For a programmer this is very nice.  I really really do not like to add 3rd party code to my apps unless i really really need to (less code == less bugs).  Especially in cases like OF and Agon, who (much to their credit) are releasing new patches fairly quickly.  This is great from a feature standpoint, but bad from a trying-to-keep-my-code-up-to-date standpoint.</p>
<p>Once you get two or three games going, just keeping up with the iPhone SDK changes is hard enough (not to mention we need to be generating new content and add polish to our apps every couple of weeks to keep sales up) adding yet another chunk of software that I have to keep up to date is yet another thing I have little time for.  From the start with our own leaderboards we tried to offload as much of the process as possible to the webservers so that we could easily and quickly update and change things without having to change the game code, Playhaven fits well with this line of thinking.</p>
<p>With Playhaven, I just add a webview and a URL.  And we are going to put a redirect script on our site and call that URL instead, so if the playhaven URL api gets changed or updated, then we just have to update our redirector and all of our games will continue to work.</p>
<p>Ok, now for the bad news:  opening up a UIWebview from within Unity is a non-trivial task. You cant actually do it from the unity engine.  (well, not yet in any case, those Unity guys are adding new stuff constantly)  Well, OK that is not entirely true.  If you have Unity iPhone Advanced then you can add a plugin that calls out to the ObjC/cocoa stuff and does all your web ui view stuff from there.  but you still need to write some ObjC/Cocoa.</p>
<p>So how do we do this?  How do we get the Playhaven page to open overtop of the unity view?</p>
<p>The simplest way is to use the tried and true 'user prefs' hack.  Since the advent of Unity iPhone Support, there have been a few enterprising developers who pioneered the technique of using the User Prefs as a communications link between Unity and Cocoa.</p>
<p>(There have been quite a few people who discussed this technique in the unity forums and I dont want to make light of their contributions, but I want to make a special shout out to blipRob aka stinkbot, who produces the fantastic <a href="http://stinkbot.com/u3d/index.html">Unity iPhone Enhancement pack</a>, which I recommend as it allows you to do so many more things than just open a UIWebView, and makes integrating the playhaven stuff as simple as adding a dozen or so lines to the enhancement pack code.  In fact he probably already has stuff in there to do it, I have an early version of the EP that I have hacked into my own thing so I havent updated recently.  But really, buy a copy of the EP and this becomes much much simpler.)</p>
<p>OK, so how does this work?</p>
<p>From unity we set a value to the PlayerPrefs, like so:</p>
<pre class="c">   PlayerPrefs.<span style="color: #202020;">SetString</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;bbcommand&quot;</span>, <span style="color: #ff0000;">&quot;BBWebUI|&quot;</span>+fullUrl<span style="color: #66cc66;">&#41;</span>;</pre>
<p>Note: you will need to have some well-formed URL in the fullUrl variable.</p>
<p>The PlayerPrefs are actually stored in the NSUserDefaults dictionary, so we can get that out from the Cocoa side like so:</p>
<pre class="objc">&nbsp;
&nbsp;
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a>* commandString = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSUserDefaults.html"><span style="color: #0000ff;">NSUserDefaults</span></a> standardUserDefaults<span style="color: #002200;">&#93;</span> objectForKey:@<span style="color: #666666;">&quot;bbcommand&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;</pre>
<p>So that is how we can get information back and forth between the Unity world and the Cocoa world.  But how do we use this to our benefit?  We need to be looking for that command to show up in the NSUserDefaults dictionary and then act on it when we see it.</p>
<p>For this to happen we need to have some extra code running besides the standard Unity stuff.  There are a few ways of handling this but the lease destructive and easiest to add into your game is to add a category extension to the AppController object in the unity code.</p>
<p>For our purposes I am going to presume that you are updated to the 1.5 unity iPhone and if you havent, then why not?  go do that now.</p>
<p>Here it is: the absolute simplest way to insert your own code into the unity code:</p>
<pre class="objc">&nbsp;
<span style="color: #339900;">#import &quot;AppController.h&quot;</span>
<span style="color: #339900;">#import &quot;BBUnityHandler.h&quot;</span>
&nbsp;
<span style="color: #0000ff;">void</span> UnityInitApplication<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span>* appPathName<span style="color: #002200;">&#41;</span>;
<span style="color: #0000ff;">void</span> UnitySetAudioSessionActive<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">bool</span> active<span style="color: #002200;">&#41;</span>;
<span style="color: #0000ff;">void</span> UnityPause<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">bool</span> pause<span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">@interface</span> AppController <span style="color: #002200;">&#40;</span>BBUnity<span style="color: #002200;">&#41;</span>
<span style="color: #ff0000;">// our two 'public' methods</span>
- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>pauseUnity;
- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>resumeUnity;
&nbsp;
<span style="color: #0000ff;">@end</span>
&nbsp;
<span style="color: #0000ff;">@implementation</span> AppController <span style="color: #002200;">&#40;</span>BBUnity<span style="color: #002200;">&#41;</span>
&nbsp;
<span style="color: #ff0000;">// override the app did finish launch method and add our single line of code</span>
- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span> applicationDidFinishLaunching:<span style="color: #002200;">&#40;</span>UIApplication*<span style="color: #002200;">&#41;</span>application
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self startUnity:application<span style="color: #002200;">&#93;</span>;
	<span style="color: #ff0000;">// start our custom code here</span>
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>BBUnityHandler sharedHandler<span style="color: #002200;">&#93;</span> startHandler:self<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #ff0000;">// this will resume the unity engine after we have paused it</span>
-<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>resumeUnity
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> setStatusBarOrientation:
                 UIInterfaceOrientationLandscapeRight<span style="color: #002200;">&#93;</span>;
&nbsp;
	UnitySetAudioSessionActive<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">true</span><span style="color: #002200;">&#41;</span>;
	UnityPause<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">false</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #ff0000;">// this will pause the unity engine</span>
- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>pauseUnity
<span style="color: #002200;">&#123;</span>
	UnitySetAudioSessionActive<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">false</span><span style="color: #002200;">&#41;</span>;
	UnityPause<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">true</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">@end</span>
&nbsp;</pre>
<p>OK, what is this doing?  Basically this is putting a hook into the unity startup process that also starts up our custom code.  In this case it calls my BBUnityHandler object and starts it up with a reference to the app controller.</p>
<p>This method is a bit different from the other unity AppController addons I have seen.  I like this way because it is clean and simple.  It keeps my code nicely separated from the AppController code.</p>
<p>So lets have a look and see what the BBUnityHandler is doing:</p>
<p>Lets us look at the first two methods we have seen: the class method: sharedHandler and the instance method startHandler:</p>
<pre class="objc">&nbsp;
<span style="color: #ff0000;">// Singleton accessor.  this is how you should ALWAYS get a reference</span>
<span style="color: #ff0000;">// to the sound controller.  Never init your own.</span>
+<span style="color: #002200;">&#40;</span>BBUnityHandler*<span style="color: #002200;">&#41;</span>sharedHandler
<span style="color: #002200;">&#123;</span>
  <span style="color: #0000ff;">static</span> BBUnityHandler *sharedHandler;
  <span style="color: #0000ff;">@synchronized</span><span style="color: #002200;">&#40;</span>self<span style="color: #002200;">&#41;</span>
  <span style="color: #002200;">&#123;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #002200;">&#40;</span>!sharedHandler<span style="color: #002200;">&#41;</span>
      sharedHandler = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>BBUnityHandler alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #0000ff;">return</span> sharedHandler;
  <span style="color: #002200;">&#125;</span>
	<span style="color: #0000ff;">return</span> sharedHandler;
<span style="color: #002200;">&#125;</span>
&nbsp;
- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>startHandler:<span style="color: #002200;">&#40;</span>AppController*<span style="color: #002200;">&#41;</span>aController;
<span style="color: #002200;">&#123;</span>
	self.unityController = aController;
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSUserDefaults.html"><span style="color: #0000ff;">NSUserDefaults</span></a> standardUserDefaults<span style="color: #002200;">&#93;</span> addObserver:self
             forKeyPath:@<span style="color: #666666;">&quot;bbcommand&quot;</span>
             options:NSKeyValueObservingOptionNew context:<span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;</pre>
<p>First up we have a simple singleton accessor method, this creates a new object if there is not one and stashes the reference in a static variable so that you always get the same one every time you call it.</p>
<p>Second we have our own start method.  This simple retains a reference to the AppController so that we can make calls against it later. Then we hook up our key value observer to keep an eye on the NSUserDefaults dictionary so we will get a notification if our command ever changes.</p>
<p>In order for the KVO to work we need to add our callback method:</p>
<pre class="objc">&nbsp;
- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>observeValueForKeyPath:<span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a> *<span style="color: #002200;">&#41;</span>keyPath
               ofObject:<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">id</span><span style="color: #002200;">&#41;</span>object
               change:<span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSDictionary.html"><span style="color: #0000ff;">NSDictionary</span></a> *<span style="color: #002200;">&#41;</span>change
               context:<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span> *<span style="color: #002200;">&#41;</span>context
<span style="color: #002200;">&#123;</span>
	<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a>* commandString = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSUserDefaults.html"><span style="color: #0000ff;">NSUserDefaults</span></a> standardUserDefaults<span style="color: #002200;">&#93;</span>
                       objectForKey:@<span style="color: #666666;">&quot;bbcommand&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #0000ff;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>commandString == <span style="color: #0000ff;">nil</span><span style="color: #002200;">&#41;</span> || <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>commandString lenght<span style="color: #002200;">&#93;</span> &amp;lt; <span style="color: #0000dd;">1</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span><span style="color: #0000ff;">return</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>self performSelectorOnMainThread:<span style="color: #0000ff;">@selector</span><span style="color: #002200;">&#40;</span>handleCommand:<span style="color: #002200;">&#41;</span>
                      withObject:commandString waitUntilDone:NO<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;</pre>
<p>This is pretty simple: grab the command string from the dictionary, check to make sure it is legit and dispatch it.  The last line is important, we jump off this thread and jump to the main thread.  Mostly we want to do this because we are going to be doing UI stuff and that is best handled on the main thread.  Why do we need to do this?  The KVO stuff is handled straight away on the same thread that the change was made, and I have no insight into the Unity black box, so I dont really know what thread I am on when this gets called so I want to get off of it and onto a known thread as quickly as I can.</p>
<p>OK, now we move to the handleCommand method which is being called on the main thread.</p>
<pre class="objc">&nbsp;
-<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>handleCommand:<span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html"><span style="color: #0000ff;">NSString</span></a>*<span style="color: #002200;">&#41;</span>commandString
<span style="color: #002200;">&#123;</span>
	<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html"><span style="color: #0000ff;">NSArray</span></a> *args = <span style="color: #002200;">&#91;</span>commandString componentsSeparatedByString: @<span style="color: #666666;">&quot;|&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #0000ff;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>args objectAtIndex:<span style="color: #0000dd;">0</span><span style="color: #002200;">&#93;</span> isEqualToString:@<span style="color: #666666;">&quot;BBWebUI&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> &amp;amp;&amp;amp; <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>args count<span style="color: #002200;">&#93;</span> &amp;gt; <span style="color: #0000dd;">1</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#91;</span>self openWebUI:args<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSUserDefaults.html"><span style="color: #0000ff;">NSUserDefaults</span></a> standardUserDefaults<span style="color: #002200;">&#93;</span> setObject:@<span style="color: #666666;">&quot;&quot;</span> forKey:@<span style="color: #666666;">&quot;bbcommand&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;</pre>
<p>Pretty simple, just parse the args into a nice array, check to make sure our command is roughly formatted right (ie there is at least one argument) and pass it on to the web ui method.  Finally we reset our command back to a blank command.  (note: this will actually cause our KVO method to get called again, but it will shunt out since there is no command there)</p>
<pre class="objc">&nbsp;
-<span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>openWebUI:<span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html"><span style="color: #0000ff;">NSArray</span></a>*<span style="color: #002200;">&#41;</span>args
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>unityController pauseUnity<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">// alloc a new window for my web view</span>
	overlayWindow = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIWindow alloc<span style="color: #002200;">&#93;</span> initWithFrame:<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIScreen mainScreen<span style="color: #002200;">&#93;</span> bounds<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">// make a toolbar and add a button right in the center</span>
	UIToolbar * toolbar = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIToolbar alloc<span style="color: #002200;">&#93;</span> initWithFrame:CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">431.0</span>, <span style="color: #0000dd;">320</span>, <span style="color: #0000dd;">49.0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	UIBarButtonItem * okButton = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIBarButtonItem alloc<span style="color: #002200;">&#93;</span>
                   initWithTitle:@<span style="color: #666666;">&quot;Back to Snowferno&quot;</span>
                   style:UIBarButtonItemStyleBordered
                   target:self action:<span style="color: #0000ff;">@selector</span><span style="color: #002200;">&#40;</span>closeWebUI<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	UIBarButtonItem * flexiSpaceItem = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIBarButtonItem alloc<span style="color: #002200;">&#93;</span>
                   initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                   target:<span style="color: #0000ff;">nil</span> action:<span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;
	UIBarButtonItem * flexiSpaceItem2 = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIBarButtonItem alloc<span style="color: #002200;">&#93;</span>
                   initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                   target:<span style="color: #0000ff;">nil</span> action:<span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	toolbar.items	= <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html"><span style="color: #0000ff;">NSArray</span></a> arrayWithObjects:flexiSpaceItem,okButton,flexiSpaceItem2,<span style="color: #0000ff;">nil</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>okButton release<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>flexiSpaceItem release<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>flexiSpaceItem2 release<span style="color: #002200;">&#93;</span>;	
&nbsp;
	<span style="color: #ff0000;">// add the toolbar to the new window and release it</span>
	<span style="color: #002200;">&#91;</span>overlayWindow addSubview:toolbar<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>toolbar release<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">// make my webview, assign self as the delegate</span>
	UIWebView * webView = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIWebView alloc<span style="color: #002200;">&#93;</span> initWithFrame:CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">320</span>, <span style="color: #0000dd;">431.0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	webView.scalesPageToFit = YES;
	webView.delegate = self;
	<span style="color: #002200;">&#91;</span>overlayWindow addSubview:webView<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">// add a spinner so the user is not waiting looking at nothing</span>
	spinner = <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIActivityIndicatorView alloc<span style="color: #002200;">&#93;</span>
              initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge<span style="color: #002200;">&#93;</span>;
	spinner.center = CGPointMake<span style="color: #002200;">&#40;</span><span style="color: #0000dd;">160.0</span>, <span style="color: #0000dd;">240.0</span><span style="color: #002200;">&#41;</span>;
	spinner.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
             UIViewAutoresizingFlexibleLeftMargin |UIViewAutoresizingFlexibleTopMargin |
             UIViewAutoresizingFlexibleBottomMargin;
	<span style="color: #002200;">&#91;</span>spinner startAnimating<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>overlayWindow addSubview:spinner<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">// show the window</span>
	<span style="color: #002200;">&#91;</span>overlayWindow makeKeyAndVisible<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">//Create a URL object.</span>
	<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURL.html"><span style="color: #0000ff;">NSURL</span></a> *url = <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURL.html"><span style="color: #0000ff;">NSURL</span></a> URLWithString:<span style="color: #002200;">&#91;</span>args objectAtIndex:<span style="color: #0000dd;">1</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">//URL Requst Object</span>
	<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURLRequest.html"><span style="color: #0000ff;">NSURLRequest</span></a> *requestObj = <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURLRequest.html"><span style="color: #0000ff;">NSURLRequest</span></a> requestWithURL:url<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #ff0000;">//Load the request in the UIWebView.</span>
	<span style="color: #002200;">&#91;</span>webView loadRequest:requestObj<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>webView release<span style="color: #002200;">&#93;</span>; <span style="color: #ff0000;">// the overlay window owns it now</span>
<span style="color: #002200;">&#125;</span></pre>
<p>Finally, the meat of our code: the actual web ui view.  The first thing we do in the longish method is pause unity.  Here is where our reference to the app controller is required.  This causes the unity engine to basically just freeze.  Now we can safely overlay our views without worrying what is going on in the engine.</p>
<p>In order to do this with minimal effect on the Unity code we are actually going to make a new window (which is fairly rare on the iPhone, you really should not need to do this very often)</p>
<p>OK, so we make a new window, then we make a toolbar with a back button and add that to our window.  Finally we add on our UIWebView and kick off the initial request.  (which is the URL that we get from the args array).</p>
<p>Since the web view will take some time to load the content, we also add a spinny indicator so that the user knows something is happening. Otherwise they have to sit and stare at a blank view for a few seconds while the URL loads.</p>
<p>OK, great! nearly done!</p>
<p>The first thing we need to do now is remove the spinner after the loading is done.  Handily we told the webview that we would be the delegate, so we get told when it has finished loading.</p>
<pre class="objc">- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>webViewDidFinishLoad:<span style="color: #002200;">&#40;</span>UIWebView *<span style="color: #002200;">&#41;</span>webView;
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>spinner removeFromSuperview<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>spinner release<span style="color: #002200;">&#93;</span>;
	spinner = <span style="color: #0000ff;">nil</span>;
<span style="color: #002200;">&#125;</span></pre>
<p>Ok, that was easy.  Now the user is happily surfing the web inside our game.  We added a nice 'Back to the game' button so that after they are done reading tips on how to slay that big bad dragon or solve that hard puzzle or whatever, they can get back into Unity.</p>
<pre class="objc">&nbsp;
- <span style="color: #002200;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #002200;">&#41;</span>closeWebUI;
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>overlayWindow release<span style="color: #002200;">&#93;</span>;
	overlayWindow = <span style="color: #0000ff;">nil</span>;
	<span style="color: #002200;">&#91;</span>unityController resumeUnity<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre>
<p>That is it.  We release the window, which makes it go away and clean up all of it's own memory, then we resume the unity engine.</p>
<p>Here it all is in one big file:<br />
<a href='http://www.snowferno.com/wp-content/uploads/2009/09/AppController_BBUnity.mm.zip'>AppController_BBUnity.mm.zip</a></p>
<p>This is all going to be in the Snowferno 1.1 release which we are submitting in the next few days, so if you want to see this in action, then pick up a copy of Snowferno! :-)  (or if you find it useful, then help up out by picking up a copy and tell your friends :-)</p>
<p><strong>UPDATE</strong>: we had a bit of a burp with our wordpress so you could not download the file.  That should be all fixed now!  Thanks Brent!</p>
<p>Cheers!<br />
-ben</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snowferno.com/2009/09/23/playhaven-unity-and-snowferno/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How-to export loops for games with Live and DP</title>
		<link>http://www.snowferno.com/2009/05/13/how-to-export-loops-for-games-with-live-and-dp/</link>
		<comments>http://www.snowferno.com/2009/05/13/how-to-export-loops-for-games-with-live-and-dp/#comments</comments>
		<pubDate>Wed, 13 May 2009 16:16:42 +0000</pubDate>
		<dc:creator>balord</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[How-To]]></category>

		<guid isPermaLink="false">http://www.snowferno.com/?p=60</guid>
		<description><![CDATA[Both Live and DP have great features for looping playback, but exporting the final audio files requires two different approaches.]]></description>
			<content:encoded><![CDATA[<img alt='' src='http://www.gravatar.com/avatar/ca32281f6b82e611c51ccf7a6863c53b?s=96&amp;d=wavatar&amp;r=G' class='avatar avatar-96 photo' height='96' width='96' /><p>Mike and I are creating the Snowferno soundtrack in <a href="http://ableton.com">Ableton Live</a> and <a href="http://www.motu.com/products/software/dp/">Digital Performer</a>.  Each track is meant to loop of course, so (at least within the limitations of the phone hardware) we want the loop's seams to be as transparent as possible.  </p>
<p>Both Live and DP have great features for looping playback, but exporting the final audio from each app as a loop requires two different approaches.</p>
<p>Live is totally loop-centric out of the box, so there is simply a switch in the "Export Audio/Video..." window to "Render as Loop".  This switch causes Live to do something pretty cool.  It makes *two* passes of the track and uses the first pass to calculate what reverb tails, delay feedback, and so on should carryover and be sounding at the <em>beginning</em> of the exported audio file.</p>
<p>DP is more linear by design, so it doesn't provide a one-click solution.  You need to fake it -- which I do by pasting a copy of the final measure of MIDI again before the first measure of the loop.  My "Bounce to Disk" selection area includes that pre-measure as well as one extra measure of breathing space beyond the last measure of the loop.   I set the "Bounce to Disk" window Import setting to "Add to Sequence" and then bounce it.  Next, I slice out the exact region of the loop from the just-bounced/imported soundbite minus the extra pre/post measures and export that soundbite from the Soundbites List.  It helps if you rename the sliced soundbite and delete the unused bits.  It's little more work, but it gets all the material that will still be sounding at the end so that it can be triggered and sounding still at the beginning of the track. Plus, I've found DP  needs a little space for things to ramp-up and down.  Adding those pre/post measures lets all my Waves processors get humming far away from the parts of the audio where a loop seam will be.</p>
<p>The final loops go in to Unity as AAC-encoded files so that the iPhone decodes it in hardware.  We're still experimenting with what the final bitrate will be -- once all the tracks are done, we're going to find the balance between great-sounding music and needless app size bloat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snowferno.com/2009/05/13/how-to-export-loops-for-games-with-live-and-dp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
