<?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/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Get Set Games &#187; code</title>
	<atom:link href="http://getsetgames.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://getsetgames.com</link>
	<description></description>
	<lastBuildDate>Thu, 12 Jan 2012 20:12:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><cloud domain='getsetgames.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<link rel="http://api.friendfeed.com/2008/03#sup" xmlns="http://www.w3.org/2005/Atom" type="application/json" href="http://friendfeed.com/api/public-sup.json#5c973c50be"/>		<item>
		<title>How to Animate Sprites in cocos2d</title>
		<link>http://getsetgames.com/2010/04/18/how-to-animate-sprites-in-cocos2d/</link>
		<comments>http://getsetgames.com/2010/04/18/how-to-animate-sprites-in-cocos2d/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 16:08:58 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[CCAnimate]]></category>
		<category><![CDATA[CCAnimation]]></category>
		<category><![CDATA[CCSprite]]></category>
		<category><![CDATA[CCSpriteSheet]]></category>
		<category><![CDATA[cocos2d]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=779</guid>
		<description><![CDATA[One of the most frequently asked questions I see about cocos2d for iPhone is &#8220;how do you animate sprites?&#8221;. This was also one of the first questions we had when [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most frequently asked questions I see about cocos2d for iPhone is &#8220;how do you animate sprites?&#8221;. This was also one of the first questions we had when developing <a href="http://getsetgames.com/games/addicus/">Addicus</a>.</p>
<p>It&#8217;s actually quite simple to do using cocos2d&#8217;s CCSpriteSheet, CCSprite and CCAnimation classes. These classes take a texture atlas and switch between frames at regular intervals. In other words: animation!</p>
<p>Here is how to animate a sprite in cocos2d in 5 steps. You can also <a href='http://getsetgames.com/wp-content/uploads/2010/04/GrossiniDance.zip'>download</a> the code for this blog post.</p>
<h3>1. Create Your Animation Texture Atlas</h3>
<p>First you need to combine all of the frames of your animation into a single graphic, called a texture atlas. You can do this by hand in an image editor like Photoshop, simply by copying and pasting all of the frames of your animation into a single file. Alternatively, there are atlas generating tools that will take a batch of image files and compile them into a texture atlas in just a couple of clicks.</p>
<p>I recommend using a Flash-based tool called <a href="http://zwoptex.zwopple.com/">Zwoptex</a> because it is officially supported by cocos2d.</p>
<p>Once you&#8217;re done, you should have an image that contains all of the frames of your animation such as the one below:</p>
<p><img src="http://getsetgames.com/wp-content/uploads/2010/04/grossini_dance_atlas.png" alt="Grossini Dance" title="Grossini Dance" width="512" height="512" class="aligncenter size-full wp-image-1399" /><br />
Incidentally, this image is included in the <a href="http://www.cocos2d-iphone.org/download">cocos2d distribution</a>.</p>
<h3>2. Create a CCSpriteSheet</h3>
<p>Once we have the texture atlas, it is time to get coding. The following code would go in the init method of a CCScene sub-class.</p>
<p>The first step in code is to create an instance of a CCSpriteSheet using your texture atlas and child it to a node in the scene. In this case we are childing it to the CCScene itself.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">CCSpriteSheet <span style="color: #002200;">*</span>danceSheet <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSpriteSheet spriteSheetWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;grossini_dance_atlas.png&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>danceSheet<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h3>3. Create a CCSprite Using Your CCSpriteSheet</h3>
<p>Next we create a CCSprite that uses the texture of the CCSpriteSheet that we just created. We then child it to the CCSpriteSheet. The rect that we initialize the CCSprite with is the first frame of the animation.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">CCSprite <span style="color: #002200;">*</span>danceSprite <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSprite spriteWithTexture<span style="color: #002200;">:</span>danceSheet.texture rect<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">85</span>, <span style="color: #2400d9;">121</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>danceSheet addChild<span style="color: #002200;">:</span>danceSprite<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h3>4. Create a CCAnimation</h3>
<p>Next we need to create a CCAnimation instance and add all frames of the animation to it. In the case of this texture atlas, we know all of the frames are the same size and there are 14 of them, so we can use a nested loop to iterate through them all and break the loop when we finish adding frame #14.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">CCAnimation <span style="color: #002200;">*</span>danceAnimation <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCAnimation animationWithName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dance&quot;</span> delay<span style="color: #002200;">:</span>0.1f<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #a61390;">int</span> frameCount <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> y <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; y &lt; <span style="color: #2400d9;">3</span>; y<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> x <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; x &lt; <span style="color: #2400d9;">5</span>; x<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		CCSpriteFrame <span style="color: #002200;">*</span>frame <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSpriteFrame frameWithTexture<span style="color: #002200;">:</span>danceSheet.texture rect<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span>x<span style="color: #002200;">*</span><span style="color: #2400d9;">85</span>,y<span style="color: #002200;">*</span><span style="color: #2400d9;">121</span>,<span style="color: #2400d9;">85</span>,<span style="color: #2400d9;">121</span><span style="color: #002200;">&#41;</span> offset<span style="color: #002200;">:</span>ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>,<span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>danceAnimation addFrame<span style="color: #002200;">:</span>frame<span style="color: #002200;">&#93;</span>;
&nbsp;
		frameCount<span style="color: #002200;">++</span>;
&nbsp;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>frameCount <span style="color: #002200;">==</span> <span style="color: #2400d9;">14</span><span style="color: #002200;">&#41;</span>
			<span style="color: #a61390;">break</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<h3>5. Run the CCAnimation on the CCSprite</h3>
<p>Finally, we need to create a CCAnimate action instance which we can run on the CCSprite. Below, we also wrap the CCAnimate action in a CCRepeatForever action that does what you would expect: repeats the animation&#8230; forever.</p>
<p>The last line actually plays the animation on the sprite using the runAction message.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">CCAnimate <span style="color: #002200;">*</span>danceAction <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCAnimate actionWithAnimation<span style="color: #002200;">:</span>danceAnimation<span style="color: #002200;">&#93;</span>;
CCRepeatForever <span style="color: #002200;">*</span>repeat <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCRepeatForever actionWithAction<span style="color: #002200;">:</span>danceAction<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>danceSprite runAction<span style="color: #002200;">:</span>repeat<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h3>Putting it All Together</h3>
<p>Here is what the above code looks like in a CCScene init method:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  DanceScene.m</span>
<span style="color: #11740a; font-style: italic;">//  GrossiniDance</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;DanceScene.h&quot;</span>
&nbsp;
&nbsp;
<span style="color: #a61390;">@implementation</span> DanceScene
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>init <span style="color: #002200;">&#123;</span>
	self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super init<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">// create the sprite sheet</span>
		CCSpriteSheet <span style="color: #002200;">*</span>danceSheet <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSpriteSheet spriteSheetWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;grossini_dance_atlas.png&quot;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>danceSheet<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #11740a; font-style: italic;">// create the sprite</span>
		CCSprite <span style="color: #002200;">*</span>danceSprite <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSprite spriteWithTexture<span style="color: #002200;">:</span>danceSheet.texture rect<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">85</span>, <span style="color: #2400d9;">121</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>danceSheet addChild<span style="color: #002200;">:</span>danceSprite<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #11740a; font-style: italic;">// position the sprite in the center of the screen</span>
		CGSize s <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>;
		danceSprite.position <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span>s.width<span style="color: #002200;">/</span><span style="color: #2400d9;">2</span>,s.height<span style="color: #002200;">/</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
&nbsp;
		<span style="color: #11740a; font-style: italic;">// create the animation</span>
		CCAnimation <span style="color: #002200;">*</span>danceAnimation <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCAnimation animationWithName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dance&quot;</span> delay<span style="color: #002200;">:</span>0.1f<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #a61390;">int</span> frameCount <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
		<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> y <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; y &lt; <span style="color: #2400d9;">3</span>; y<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> x <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; x &lt; <span style="color: #2400d9;">5</span>; x<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
				CCSpriteFrame <span style="color: #002200;">*</span>frame <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCSpriteFrame frameWithTexture<span style="color: #002200;">:</span>danceSheet.texture rect<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span>x<span style="color: #002200;">*</span><span style="color: #2400d9;">85</span>,y<span style="color: #002200;">*</span><span style="color: #2400d9;">121</span>,<span style="color: #2400d9;">85</span>,<span style="color: #2400d9;">121</span><span style="color: #002200;">&#41;</span> offset<span style="color: #002200;">:</span>ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>,<span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
				<span style="color: #002200;">&#91;</span>danceAnimation addFrame<span style="color: #002200;">:</span>frame<span style="color: #002200;">&#93;</span>;
&nbsp;
				frameCount<span style="color: #002200;">++</span>;
&nbsp;
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>frameCount <span style="color: #002200;">==</span> <span style="color: #2400d9;">14</span><span style="color: #002200;">&#41;</span>
					<span style="color: #a61390;">break</span>;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span>
&nbsp;
		<span style="color: #11740a; font-style: italic;">// create the action</span>
		CCAnimate <span style="color: #002200;">*</span>danceAction <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCAnimate actionWithAnimation<span style="color: #002200;">:</span>danceAnimation<span style="color: #002200;">&#93;</span>;
		CCRepeatForever <span style="color: #002200;">*</span>repeat <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CCRepeatForever actionWithAction<span style="color: #002200;">:</span>danceAction<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #11740a; font-style: italic;">// run the action</span>
		<span style="color: #002200;">&#91;</span>danceSprite runAction<span style="color: #002200;">:</span>repeat<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">@end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2010/04/18/how-to-animate-sprites-in-cocos2d/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2010/04/grossini_dance_atlas-150x150.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2010/04/grossini_dance_atlas.png" medium="image">
			<media:title type="html">Grossini Dance</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2010/04/grossini_dance_atlas-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>How to Open the SMS App With a Phone Number</title>
		<link>http://getsetgames.com/2009/12/24/iphonedev-advent-tip-24-how-to-open-the-sms-app-with-a-phone-number/</link>
		<comments>http://getsetgames.com/2009/12/24/iphonedev-advent-tip-24-how-to-open-the-sms-app-with-a-phone-number/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 19:49:49 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1073</guid>
		<description><![CDATA[It&#8217;s the day before Christmas, so this is the last post in our advent tip series. We&#8217;ve really enjoyed writing about so many little things that are so easily accomplished [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s the day before Christmas, so this is the last post in our <a href="http://getsetgames.com/tag/advent/">advent tip series</a>. We&#8217;ve really enjoyed writing about so many little things that are so easily accomplished with the iPhone SDK and we hope that they&#8217;ve helped you in developing your iPhone apps. This may be the last blog post in this series, but you can be sure we&#8217;ll still be writing about our adventures with iPhone, cocos2d and OpenFeint development.</p>
<h2>Less Yap, More Tip</h2>
<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" alt="" title="messages" width="69" height="85" class="alignright size-full wp-image-1074" />Today&#8217;s advent tip is how to open the Messages app (aka the SMS app) with a specific phone number populated in the <strong>To:</strong> field. This is accomplished with great ease because the iPhone has implemented the <strong>sms:</strong> URI scheme. Therefore, we can use the UIApplication class&#8217; openURL method, which we have seen before when we discussed how to <a href="http://getsetgames.com/2009/12/12/iphonedev-advent-tip-12-how-to-dial-a-phone-number/">dial a phone number</a>, <a href="http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/">pre-compose an email</a>, and yes, even <a href="http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/">open a URL</a>.</p>
<p>So here it is: the one line of code you need to pop open the SMS app with a phone number:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> openURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;sms:5555555555&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/24/iphonedev-advent-tip-24-how-to-open-the-sms-app-with-a-phone-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" medium="image">
			<media:title type="html">messages</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Suspend Touch Input</title>
		<link>http://getsetgames.com/2009/12/23/iphonedev-advent-tip-23-how-to-suspend-touch-input/</link>
		<comments>http://getsetgames.com/2009/12/23/iphonedev-advent-tip-23-how-to-suspend-touch-input/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 00:06:43 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1069</guid>
		<description><![CDATA[Have you ever encountered a situation where you wish you could just pause and resume touch input while developing an iPhone app? Sure, you could always increase the complexity of [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever encountered a situation where you wish you could just pause and resume touch input while developing an iPhone app? Sure, you could always increase the complexity of your input handling by considering the state of any number of variables, but there are some times when just switching input off and on would be easiest.</p>
<p>We had a number of cases like this when developing <a href="http://getsetgames.com/games/addicus/">Addicus</a>. In particular, because we have both the game and game over screens operating in a single cocos2d scene, we were noticing some bugs that occurred because of the way we handled input. This was solved by suspending input for brief periods of time.</p>
<h2>Input Goes Off</h2>
<p>Here&#8217;s how to tell your iPhone app to stop responding to touch events in just one line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> beginIgnoringInteractionEvents<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h2>Input Goes On</h2>
<p>And as you might expect, resuming responding to touch input events is similarly easy:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span> endIgnoringInteractionEvents<span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/23/iphonedev-advent-tip-23-how-to-suspend-touch-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>How to Log to the Console Using NSLog</title>
		<link>http://getsetgames.com/2009/12/22/iphonedev-advent-tip-22-how-to-log-to-the-console-using-nslog/</link>
		<comments>http://getsetgames.com/2009/12/22/iphonedev-advent-tip-22-how-to-log-to-the-console-using-nslog/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 23:56:19 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[NSLog]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1056</guid>
		<description><![CDATA[Xcode has a built in console that provides an invaluable debugging tool for iPhone app development. It gives you a way to monitor text output from your app live at [...]]]></description>
			<content:encoded><![CDATA[<p>Xcode has a built in console that provides an invaluable debugging tool for iPhone app development. It gives you a way to monitor text output from your app live at runtime. It works both for apps being debugged in the simulator and on a device.</p>
<h2>NSLog</h2>
<p>Logging statements to the console is just as easy as you would expect it to be in iPhone app development. Just run the NSLog function like so:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;hello world&quot;</span><span style="color: #002200;">&#41;</span>;</pre></div></div>

<h2>Format Specifiers</h2>
<p>The NSLog statement also supports <a href="http://getsetgames.com/2009/12/19/iphonedev-advent-tip-19-how-to-format-an-nsstring/">string formatting specifiers</a>, so you can also output the values of variables to the console with just one line. Below are some examples:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> str <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;hello world&quot;</span>;
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@&quot;</span>, str<span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #a61390;">int</span> num <span style="color: #002200;">=</span> <span style="color: #2400d9;">10</span>;
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%i&quot;</span>, num<span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #a61390;">float</span> price <span style="color: #002200;">=</span> <span style="color: #2400d9;">1.99</span>;
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%f&quot;</span>, price<span style="color: #002200;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/22/iphonedev-advent-tip-22-how-to-log-to-the-console-using-nslog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
	</item>
		<item>
		<title>How to Upgrade Your iPhone Game to OpenFeint 2.4</title>
		<link>http://getsetgames.com/2009/12/21/iphonedev-advent-tip-21-how-to-upgrade-your-iphone-game-to-openfeint-2-4/</link>
		<comments>http://getsetgames.com/2009/12/21/iphonedev-advent-tip-21-how-to-upgrade-your-iphone-game-to-openfeint-2-4/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 15:40:28 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[openfeint]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1018</guid>
		<description><![CDATA[If you were watching twitter this week, you might have heard that OpenFeint 2.4 was quietly released to developers. This update surely stretches the definition of &#8220;point release&#8221; because it [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/of_logo.png" alt="" title="of_logo" width="232" height="61" class="alignright size-full wp-image-1043" />If you were watching twitter this week, you might have heard that <a href="http://www.openfeint.com">OpenFeint 2.4</a> was <a href="http://twitter.com/openfeint/status/6806021596">quietly released</a> to developers. This update surely stretches the definition of &#8220;point release&#8221; because it is packed with awesome new features as well as a complete overhaul of the interface.</p>
<p>If you are upgrading to OpenFeint 2.4 from a previous version, then it is not as easy as replacing the source code. However, it is still quite easy to make the upgrade if you just keep a few things in mind. Here&#8217;s what you need to know:</p>
<h2>Disabling Chat</h2>
<p>If you were previously disabling the chat feature in order to meet a certain parental ratings requirement, then you would be doing so by passing the <strong>OpenFeintSettingDisableChat</strong> setting into the initializeWithProductKey method. Since chat is not the only user-genereated content in OpenFeint 2.4, this setting name has been changed to <strong>OpenFeintSettingDisableUserGeneratedContent</strong>. Below is the new way to initialize OpenFeint with chat (and all user-generated content) disabled:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSDictionary</span><span style="color: #002200;">*</span> settings <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span>
			<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span>UIInterfaceOrientationLandscapeRight<span style="color: #002200;">&#93;</span>, OpenFeintSettingDashboardOrientation,
			<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Addicus&quot;</span>, OpenFeintSettingShortDisplayName,
			<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithBool<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>, OpenFeintSettingDisableUserGeneratedContent,
			<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
OFDelegatesContainer<span style="color: #002200;">*</span> delegates <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>OFDelegatesContainer containerWithOpenFeintDelegate<span style="color: #002200;">:</span>self
								andChallengeDelegate<span style="color: #002200;">:</span>self
								andNotificationDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span>OpenFeint initializeWithProductKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;MY_PRODUCT_KEY&quot;</span>
			andSecret<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;MY_PRODUCT_SECRET&quot;</span>
			andDisplayName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Addicus&quot;</span>
			andSettings<span style="color: #002200;">:</span>settings
			andDelegates<span style="color: #002200;">:</span>delegates<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h2>New Library Dependencies</h2>
<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-21-at-10.22.40-AM-298x300.png" alt="" title="Screen shot 2009-12-21 at 10.22.40 AM" width="298" height="300" class="alignright size-medium wp-image-1039" />If you replaced OpenFeint 2.3.x in your project with the new 2.4 source, you might have gotten a bunch of nasty errors upon building it. This is because the OpenFeint 2.4 requires more libraries to be added to your target. You need to add the following 3 frameworks to your target to get your OpenFeint 2.4 game to build successfully:</p>
<ul>
<li>CFNetwork</li>
<li>CoreLocation</li>
<li>MapKit</li>
</ul>
<p><br/><br />
<br/></p>
<h2>Achievements and Social Networks</h2>
<p>In OpenFeint 2.4, unlocking an achievement no longer prompts the user to notify their friends on Twitter and Facebook by default. However, you can restore this behaviour by setting the <strong>OpenFeintSettingPromptToPostAchievementUnlock</strong> setting to be true at the time of initialization. Below is how to initialize OpenFeint 2.4 with prompts to post achievements to social networks enabled:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSDictionary</span><span style="color: #002200;">*</span> settings <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span>
			<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span>UIInterfaceOrientationLandscapeRight<span style="color: #002200;">&#93;</span>, OpenFeintSettingDashboardOrientation,
			<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Addicus&quot;</span>, OpenFeintSettingShortDisplayName,
			<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithBool<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>, OpenFeintSettingPromptToPostAchievementUnlock,
			<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
OFDelegatesContainer<span style="color: #002200;">*</span> delegates <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>OFDelegatesContainer containerWithOpenFeintDelegate<span style="color: #002200;">:</span>self
								andChallengeDelegate<span style="color: #002200;">:</span>self
								andNotificationDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span>OpenFeint initializeWithProductKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;MY_PRODUCT_KEY&quot;</span>
			andSecret<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;MY_PRODUCT_SECRET&quot;</span>
			andDisplayName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Addicus&quot;</span>
			andSettings<span style="color: #002200;">:</span>settings
			andDelegates<span style="color: #002200;">:</span>delegates<span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/21/iphonedev-advent-tip-21-how-to-upgrade-your-iphone-game-to-openfeint-2-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/of_logo-150x61.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/of_logo.png" medium="image">
			<media:title type="html">of_logo</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/of_logo-150x61.png" />
		</media:content>
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-21-at-10.22.40-AM.png" medium="image">
			<media:title type="html">Screen shot 2009-12-21 at 10.22.40 AM</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-21-at-10.22.40-AM-150x150.png" />
		</media:content>
	</item>
		<item>
		<title>How to Play a Video With MPMoviePlayerController</title>
		<link>http://getsetgames.com/2009/12/20/iphonedev-advent-tip-20-how-to-play-a-video-with-mpmovieplayercontroller/</link>
		<comments>http://getsetgames.com/2009/12/20/iphonedev-advent-tip-20-how-to-play-a-video-with-mpmovieplayercontroller/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 21:27:32 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[MPMoviePlayerController]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1022</guid>
		<description><![CDATA[Splash screens, cutscenes, tutorials or just good old content. There are plenty of reasons to need to play a video in your iPhone app. Here&#8217;s how to do it in [...]]]></description>
			<content:encoded><![CDATA[<p>Splash screens, cutscenes, tutorials or just good old content. There are plenty of reasons to need to play a video in your iPhone app. Here&#8217;s how to do it in 3 simple steps:</p>
<p>1. Add the MediaPlayer framework to your target.</p>
<p>2. Import the MediaPlayer header file in the file you intend to begin playing the video in, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;MediaPlayer/MediaPlayer.h&gt;</span></pre></div></div>

<p>3a. Now we can stream a video from the internet like so:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSURL</span> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.example.com/myvideo.m4v&quot;</span><span style="color: #002200;">&#93;</span>;
MPMoviePlayerController <span style="color: #002200;">*</span>player <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MPMoviePlayerController alloc<span style="color: #002200;">&#93;</span> initWithContentURL<span style="color: #002200;">:</span>url<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>player play<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>3b. Alternately, we can stream a video that you include in your app bundle. To stream a file called <em>myvideo.m4v</em>, you would run the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;myvideo&quot;</span> ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;m4v&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSURL</span> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> fileURLWithPath<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span>;
&nbsp;
MPMoviePlayerController <span style="color: #002200;">*</span>player <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MPMoviePlayerController alloc<span style="color: #002200;">&#93;</span> initWithContentURL<span style="color: #002200;">:</span>url<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>player play<span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/20/iphonedev-advent-tip-20-how-to-play-a-video-with-mpmovieplayercontroller/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
	</item>
		<item>
		<title>How to Format an NSString</title>
		<link>http://getsetgames.com/2009/12/19/iphonedev-advent-tip-19-how-to-format-an-nsstring/</link>
		<comments>http://getsetgames.com/2009/12/19/iphonedev-advent-tip-19-how-to-format-an-nsstring/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 03:08:02 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=1010</guid>
		<description><![CDATA[It&#8217;s back to basics with today&#8217;s advent tip. I would be surprised if anything short of ALL developers have had a need to format strings at one time or another. [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s back to basics with today&#8217;s advent tip. I would be surprised if anything short of ALL developers have had a need to format strings at one time or another. iPhone app development is no exception.</p>
<p>String formatting allows you to build a string based on a template and varying types of values. For example, if I am keeping track of a player&#8217;s score as an integer and I want to display a string to the player that celebrates their score by saying &#8220;You scored 2600! Way to go!&#8221;, then I need string formatting to get the correct score in the middle of that string.</p>
<h2>How to Do It</h2>
<p>Below is an example of how to build the above NSString. This example formats a string with an integer in it using the <strong>%i</strong> format specifier.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">int</span> score <span style="color: #002200;">=</span> <span style="color: #2400d9;">2600</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> scoreString <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;You scored %i! Way to go!&quot;</span>,score<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h2>Format Specifiers</h2>
<p>But string formatting doesn&#8217;t stop at putting integers in strings. Below are some of the most common format specifiers for other value types:</p>
<table>
<tr>
<td><strong>Specifier</strong></td>
<td><strong>Purpose</strong></td>
</tr>
<tr>
<td>%i</td>
<td>integer</td>
</tr>
<tr>
<td>%f</td>
<td>float</td>
</tr>
<tr>
<td>%@</td>
<td>Objective-C object (commonly used to specify another NSString)</td>
</tr>
<tr>
<td>%x</td>
<td>hexadecimal</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/19/iphonedev-advent-tip-19-how-to-format-an-nsstring/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
	</item>
		<item>
		<title>How to Prevent the iPhone from Sleeping</title>
		<link>http://getsetgames.com/2009/12/17/iphonedev-advent-tip-17-how-to-prevent-the-iphone-from-sleeping/</link>
		<comments>http://getsetgames.com/2009/12/17/iphonedev-advent-tip-17-how-to-prevent-the-iphone-from-sleeping/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 23:10:53 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=994</guid>
		<description><![CDATA[Left idle, the iPhone goes into sleep mode after about a minute. This narcoleptic behaviour saves on battery life, but there are situations where you would not want the device [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep.jpeg" alt="put-the-iphone-to-sleep" title="put-the-iphone-to-sleep" width="200" class="alignright size-full wp-image-995" /></p>
<p>Left idle, the iPhone goes into sleep mode after about a minute. This narcoleptic behaviour saves on battery life, but there are situations where you would not want the device to go to sleep. For instance, in the middle of a multiplayer game that is turn-based, such as chess. You could wait for longer than a minute for your opponent to make make their move and you wouldn&#8217;t want to miss it when they did.</p>
<p>To keep the iPhone awake and alert, simply run the following line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>.idleTimerDisabled <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;</pre></div></div>

<p>Do use this tip sparingly though. The iPhone&#8217;s power is unmatched, to be sure, but unfortunately it is not unlimited. </p>
]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/17/iphonedev-advent-tip-17-how-to-prevent-the-iphone-from-sleeping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep-150x150.jpg" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep.jpeg" medium="image">
			<media:title type="html">put-the-iphone-to-sleep</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep-150x150.jpg" />
		</media:content>
	</item>
		<item>
		<title>How to Show the Network Activity Indicator</title>
		<link>http://getsetgames.com/2009/12/16/iphonedev-advent-tip-16-how-to-show-the-network-activity-indicator/</link>
		<comments>http://getsetgames.com/2009/12/16/iphonedev-advent-tip-16-how-to-show-the-network-activity-indicator/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 03:17:32 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=987</guid>
		<description><![CDATA[The network activity indicator is like the UIActivityIndicatorView we previously discussed, only it sits on the status bar, it is smaller, and believe it or not, it is even easier [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM.png" alt="Screen shot 2009-12-16 at 10.14.26 PM" title="Screen shot 2009-12-16 at 10.14.26 PM" width="172" height="143" class="alignright size-full wp-image-990" />The network activity indicator is like the <a href="http://getsetgames.com/2009/12/03/iphonedev-advent-tip-3-how-to-display-an-activity-indicator-with-uiactivityindicatorview/">UIActivityIndicatorView</a> we previously discussed, only it sits on the status bar, it is smaller, and believe it or not, it is even easier to manipulate. It&#8217;s the little rotating wheel of bars (pictured right) that shows up on the status bar whenever your iPhone is accessing the network.</p>
<h2>Show It</h2>
<p>If you would like to let your users know that your iPhone app is currently swapping data with the network, you can do so with this simple line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>.networkActivityIndicatorVisible <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;</pre></div></div>

<h2>Hide It</h2>
<p>You guessed it: once you&#8217;re done showing it, to hide it again, just set the same UIApplication property to NO like so.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>.networkActivityIndicatorVisible <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/16/iphonedev-advent-tip-16-how-to-show-the-network-activity-indicator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM-150x143.png" />
		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM.png" medium="image">
			<media:title type="html">Screen shot 2009-12-16 at 10.14.26 PM</media:title>
			<media:thumbnail url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM-150x143.png" />
		</media:content>
	</item>
		<item>
		<title>How to Make the iPhone Vibrate</title>
		<link>http://getsetgames.com/2009/12/15/iphonedev-advent-tip-15-how-to-make-the-iphone-vibrate/</link>
		<comments>http://getsetgames.com/2009/12/15/iphonedev-advent-tip-15-how-to-make-the-iphone-vibrate/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 00:13:36 +0000</pubDate>
		<dc:creator>Derek van Vliet</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[AudioToolbox]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[vibrate]]></category>

		<guid isPermaLink="false">http://getsetgames.com/?p=983</guid>
		<description><![CDATA[The iPhone is capable of dazzling the user eyes by pushing impressive graphics around its screen and tickling their ears with a lot of audio to go with it, but [...]]]></description>
			<content:encoded><![CDATA[<p>The iPhone is capable of dazzling the user eyes by pushing impressive graphics around its screen and tickling their ears with a lot of audio to go with it, but you may want to give users of your iPhone app some additional sensory experience on top of that. You can do this by making the device vibrate.</p>
<p>We actually use the Audio framework to vibrate device. Here is how to do it in 3 simple steps:</p>
<p>1. Add the AudioToolbox framework to your target.</p>
<p>2. In the file you intend to trigger a vibration, import the AudioToolbox header file:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;AudioToolbox/AudioToolbox.h&gt;</span></pre></div></div>

<p>3. Finally, call the following line to make the device vibrate:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">AudioServicesPlaySystemSound<span style="color: #002200;">&#40;</span>kSystemSoundID_Vibrate<span style="color: #002200;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://getsetgames.com/2009/12/15/iphonedev-advent-tip-15-how-to-make-the-iphone-vibrate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
	</item>
	</channel>
</rss>

