<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>JohnnyWorks</title>
	
	<link>http://johnehartzog.com</link>
	<description>Programming projects and sample code</description>
	<lastBuildDate>Thu, 25 Mar 2010 18:44:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Johnnyworks" /><feedburner:info uri="johnnyworks" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>StickWars gets a Second Wind</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/CW0FzCPxsCs/</link>
		<comments>http://johnehartzog.com/2009/12/stickwars-gets-a-second-wind/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 13:50:13 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Slime Ball]]></category>
		<category><![CDATA[StickWars]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=415</guid>
		<description><![CDATA[StickWars was featured on Apple&#8217;s list of best games of 2009 and the list of best selling apps of 2009. Each of the lists features 30 apps each and are very well promoted within iTunes. I have no idea why they would chose to feature it twice on somewhat similar lists, but I can imagine it has [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://itunes.apple.com/us/app/stickwars/id309527804?mt=8">StickWars</a> was featured on Apple&#8217;s list of <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewCustomPage?name=pageiTunesRewind09SL_BestGames">best games of 2009</a> and the list of <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewCustomPage?name=pageiTunesRewind09SL_TSGames">best selling apps of 2009</a>. Each of the lists features 30 apps each and are very well promoted within iTunes. I have no idea why they would chose to feature it twice on somewhat similar lists, but I can imagine it has to do something with the ~3 month delay getting my last update approved. While this is nothing but a guess, if true then it&#8217;s fantastic of Apple to take that into account. Or maybe they just really like playing StickWars&#8230;</p>
<p>Between the new visibility from being featured as well as what I imagine to be  a lot of word of mouth <a href="http://twitter.com/#search?q=stickwars">promotion</a> during the holiday season as people open their new iPod Touches, sales have jumped up and StickWars has risen up the lists. It is now the top 40 paid app in the US, and it is actually back on the top grossing list at 99. For anybody who doesn&#8217;t know, the spike in sales of apps during Christmas holiday is like a big fat Christmas bonus to iPhone developers, and it&#8217;s a great feeling getting this final push before headed into the new year.</p>
<p>I meant to make a long post detailing my frustrating experience trying to get version 1.7 of StickWars approved for over 3 months, but I&#8217;ll sum it up by saying Apple had some unexpected technical problems with their approval process, they worked on it for a while, fixed the issues, and called me personally to help StickWars through the approval process once the issues were fixed. While it was very frustrating to develop a big release (including all those new challenge mini-games available as an in-app purchase) and then have to sit on it as StickWars slipped down the charts for 3 months, Apple has done what they can to make the process quicker and less painful, and being featured prominently twice by them is a unexpected gift that really helps me let go of my anger over the previous delay <img src='http://johnehartzog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Slime Ball has completed its first cycle of rising up and then falling back down the charts. Both the <a href="http://itunes.apple.com/us/app/slime-ball-lite/id340333047?mt=8">free</a> and the <a href="http://itunes.apple.com/us/app/slime-ball/id339129315?mt=8">paid</a> version are now of the top 100 lists, although we have some fun updates planned that will hopefully breath some life back into them. It&#8217;s time to go hit up the keyboard and get back to work&#8230;</p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/CW0FzCPxsCs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/12/stickwars-gets-a-second-wind/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/12/stickwars-gets-a-second-wind/</feedburner:origLink></item>
		<item>
		<title>Slime Ball Release on the AppStore</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/Mfit93TmNGU/</link>
		<comments>http://johnehartzog.com/2009/12/slime-ball-release-on-the-appstore/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 16:43:08 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Slime Ball]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=409</guid>
		<description><![CDATA[I finally have something new I&#8217;ve worked on in the AppStore! While the game is created and owned by Pinger, I had a part in bringing it to life.
The game is called Slime Ball, and it&#8217;s a fun remake of Slime Volleyball. It&#8217;s very simple to pick up and play, and is addictive to play [...]]]></description>
			<content:encoded><![CDATA[<p>I finally have something new I&#8217;ve worked on in the AppStore! While the game is created and owned by <a href="http://pinger.com" target="_blank">Pinger</a>, I had a part in bringing it to life.</p>
<p>The game is called Slime Ball, and it&#8217;s a fun remake of Slime Volleyball. It&#8217;s very simple to pick up and play, and is addictive to play both against the computer and against another human.</p>
<p><a href="http://" target="_blank">Paid version</a><br />
<a href="http://itunes.apple.com/us/app/slime-ball-lite/id340333047?mt=8" target="_blank"> Lite version</a></p>
<p>I had a fun time working on it and can say that I believe most people who try it out will find it fun. We spent a ton of time tweaking the controls and other subtle elements that really make gameplay fun, and I think that effort shows in this release.</p>
<p>You can play against many levels of computer players which get progressively more difficult, or you can play against another player over Bluetooth. The game uses OpenFeint to track achievements and leaderboards.</p>
<p><a href="http://johnehartzog.com/wp-content/uploads/2009/12/slimeball_ss01.png"><img title="slimeball_ss01" src="http://johnehartzog.com/wp-content/uploads/2009/12/slimeball_ss01.png" alt="" width="480" height="320" /></a></p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/Mfit93TmNGU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/12/slime-ball-release-on-the-appstore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/12/slime-ball-release-on-the-appstore/</feedburner:origLink></item>
		<item>
		<title>StickWars Ultimate Challenge hits the AppStore</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/6nl3cTqkOqA/</link>
		<comments>http://johnehartzog.com/2009/10/stickwars-ultimate-challenge-hits-the-appstore/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 20:33:00 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[StickWars]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=405</guid>
		<description><![CDATA[I&#8217;m pleased to announce that StickWars Ultimate Challenge is live on the AppStore. It is a collection of mini-games based on the addictive StickWars gameplay, and allows you to directly challenge your OpenFeint friends to compete for the top scores.
You can read more about it here, or just click here to visit the iTunes page.
I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pleased to announce that <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=332426830&amp;mt=8">StickWars Ultimate Challenge</a> is live on the AppStore. It is a collection of mini-games based on the addictive StickWars gameplay, and allows you to directly challenge your OpenFeint friends to compete for the top scores.</p>
<p>You can read more about it <a href="http://johnehartzog.com/forums/showthread.php?t=695" target="_blank">here</a>, or just click <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=332426830&amp;mt=8">here</a> to visit the iTunes page.</p>
<p>I have been working on this update for months, and while it was originally slated to be an in-app purchase included with StickWars, technical limitations imposed by Apple dictated  that I release it as a completely separate app. You can try out two of these minigames for free in StickWars or StickWars Lite version 1.7. Have fun, and as always I welcome all feedback, so visit my <a href="http://johnehartzog.com/forums/" target="_blank">forums</a> and let me know what you think.</p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/6nl3cTqkOqA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/10/stickwars-ultimate-challenge-hits-the-appstore/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/10/stickwars-ultimate-challenge-hits-the-appstore/</feedburner:origLink></item>
		<item>
		<title>Easy To Create Buttons with Cocos2D</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/8wm_e1QvuXo/</link>
		<comments>http://johnehartzog.com/2009/10/easy-to-create-buttons-with-cocos2d/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 20:55:43 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[cocos2d iPhone]]></category>
		<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=396</guid>
		<description><![CDATA[Those of you who use cocos2d a lot might understand why I created this class as some point. Hopefully it may save some of you those nasty 5 line blobs that you normally need to create a simple button. Usage is simple, just do:

&#91;self addChild:&#91;Button buttonWithText:@&#34;back&#34; atPosition:ccp&#40;80, 50&#41; target:self selector:@selector&#40;back:&#41;&#93;&#93;;
&#91;self addChild:&#91;Button buttonWithImage:@&#34;openFeint.png&#34; atPosition:ccp&#40;400, 50&#41; target:self [...]]]></description>
			<content:encoded><![CDATA[<p>Those of you who use cocos2d a lot might understand why I created this class as some point. Hopefully it may save some of you those nasty 5 line blobs that you normally need to create a simple button. Usage is simple, just do:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>Button buttonWithText<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;back&quot;</span> atPosition<span style="color: #002200;">:</span>ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">80</span>, <span style="color: #2400d9;">50</span><span style="color: #002200;">&#41;</span> target<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>back<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>Button buttonWithImage<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;openFeint.png&quot;</span> atPosition<span style="color: #002200;">:</span>ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">400</span>, <span style="color: #2400d9;">50</span><span style="color: #002200;">&#41;</span> target<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>openOpenFeint<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p><script type="text/javascript"><!--
google_ad_client = "pub-1151609318119170";
/* 468x60, created 3/31/10 */
google_ad_slot = "7808045430";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>You&#8217;ll need to create your own button.png and button_p.png (the second one is the image shown when you are touching the button). Also you&#8217;ll need to choose your own font. Here is the code&#8230;</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;">//  Button.h</span>
<span style="color: #11740a; font-style: italic;">//  StickWars - Siege</span>
<span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  Created by EricH on 8/3/09.</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #a61390;">@interface</span> Button <span style="color: #002200;">:</span> Menu <span style="color: #002200;">&#123;</span>
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithText<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>text atPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>position target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>file atPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>position target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #a61390;">@interface</span> ButtonItem <span style="color: #002200;">:</span> MenuItem <span style="color: #002200;">&#123;</span>
	Sprite <span style="color: #002200;">*</span>back;
	Sprite <span style="color: #002200;">*</span>backPressed;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithText<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>text target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>file target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithText<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>text target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>file target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector;
<span style="color: #a61390;">@end</span></pre></div></div>


<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;">//  Button.m</span>
<span style="color: #11740a; font-style: italic;">//  StickWars - Siege</span>
<span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  Created by EricH on 8/3/09.</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;Button.h&quot;</span>
&nbsp;
&nbsp;
<span style="color: #a61390;">@implementation</span> Button
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithText<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>text atPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>position target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector <span style="color: #002200;">&#123;</span>
	Menu <span style="color: #002200;">*</span>menu <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>Menu menuWithItems<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>ButtonItem buttonWithText<span style="color: #002200;">:</span>text target<span style="color: #002200;">:</span>target selector<span style="color: #002200;">:</span>selector<span style="color: #002200;">&#93;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	menu.position <span style="color: #002200;">=</span> position;
	<span style="color: #a61390;">return</span> menu;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>file atPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>position target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector <span style="color: #002200;">&#123;</span>
	Menu <span style="color: #002200;">*</span>menu <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>Menu menuWithItems<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>ButtonItem buttonWithImage<span style="color: #002200;">:</span>file target<span style="color: #002200;">:</span>target selector<span style="color: #002200;">:</span>selector<span style="color: #002200;">&#93;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	menu.position <span style="color: #002200;">=</span> position;
	<span style="color: #a61390;">return</span> menu;
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #a61390;">@implementation</span> ButtonItem
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithText<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>text target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self alloc<span style="color: #002200;">&#93;</span> initWithText<span style="color: #002200;">:</span>text target<span style="color: #002200;">:</span>target selector<span style="color: #002200;">:</span>selector<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>buttonWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>file target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self alloc<span style="color: #002200;">&#93;</span> initWithImage<span style="color: #002200;">:</span>file target<span style="color: #002200;">:</span>target selector<span style="color: #002200;">:</span>selector<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithText<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>text target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithTarget<span style="color: #002200;">:</span>target selector<span style="color: #002200;">:</span>selector<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		back <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Sprite spriteWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;button.png&quot;</span><span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
		back.anchorPoint <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>;
		backPressed <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Sprite spriteWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;button_p.png&quot;</span><span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
		backPressed.anchorPoint <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;">&#91;</span>self addChild<span style="color: #002200;">:</span>back<span style="color: #002200;">&#93;</span>;
&nbsp;
		self.contentSize <span style="color: #002200;">=</span> back.contentSize;
&nbsp;
		Label<span style="color: #002200;">*</span> textLabel <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>Label labelWithString<span style="color: #002200;">:</span>text fontName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;take_out_the_garbage&quot;</span> fontSize<span style="color: #002200;">:</span><span style="color: #2400d9;">22</span><span style="color: #002200;">&#93;</span>;
		textLabel.position <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span>self.contentSize.width <span style="color: #002200;">/</span> <span style="color: #2400d9;">2</span>, self.contentSize.height <span style="color: #002200;">/</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
		textLabel.anchorPoint <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0.5</span>, <span style="color: #2400d9;">0.3</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>textLabel z<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>file target<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>target selector<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">SEL</span><span style="color: #002200;">&#41;</span>selector <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithTarget<span style="color: #002200;">:</span>target selector<span style="color: #002200;">:</span>selector<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
		back <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Sprite spriteWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;button.png&quot;</span><span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
		back.anchorPoint <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>;
		backPressed <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Sprite spriteWithFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;button_p.png&quot;</span><span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
		backPressed.anchorPoint <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;">&#91;</span>self addChild<span style="color: #002200;">:</span>back<span style="color: #002200;">&#93;</span>;
&nbsp;
		self.contentSize <span style="color: #002200;">=</span> back.contentSize;
&nbsp;
		Sprite<span style="color: #002200;">*</span> image <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>Sprite spriteWithFile<span style="color: #002200;">:</span>file<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>image z<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
		image.position <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span>self.contentSize.width <span style="color: #002200;">/</span> <span style="color: #2400d9;">2</span>, self.contentSize.height <span style="color: #002200;">/</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> selected <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self removeChild<span style="color: #002200;">:</span>back cleanup<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>backPressed<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>super selected<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> unselected <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self removeChild<span style="color: #002200;">:</span>backPressed cleanup<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>back<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>super unselected<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// this prevents double taps</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>activate <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>super activate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>self setIsEnabled<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>self schedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>resetButton<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> interval<span style="color: #002200;">:</span><span style="color: #2400d9;">0.5</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>resetButton<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>ccTime<span style="color: #002200;">&#41;</span>dt <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self unschedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>resetButton<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>self setIsEnabled<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>dealloc <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>back release<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>backPressed release<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><script type="text/javascript"><!--
google_ad_client = "pub-1151609318119170";
/* 468x60, created 3/31/10 */
google_ad_slot = "7808045430";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/8wm_e1QvuXo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/10/easy-to-create-buttons-with-cocos2d/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/10/easy-to-create-buttons-with-cocos2d/</feedburner:origLink></item>
		<item>
		<title>2D Scrolling Game with Cocos2D TileMap with Zoom!</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/VkcE-Xqa4_Q/</link>
		<comments>http://johnehartzog.com/2009/10/2d-scrolling-game-with-cocos2d-tilemap-with-zoom/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 14:39:14 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[cocos2d iPhone]]></category>
		<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=391</guid>
		<description><![CDATA[



A common question I see on the cocos2d forums is &#8216;when I want to make my game scroll, do I move the camera or the layer?&#8217; or some variant of that. I also got some more detailed questions about how to make a functioning 2D scroller, so I&#8217;m going to described how I got it [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1151609318119170";
/* 468x60, created 3/31/10 */
google_ad_slot = "7808045430";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>A common question I see on the cocos2d forums is &#8216;when I want to make my game scroll, do I move the camera or the layer?&#8217; or some variant of that. I also got some more detailed questions about how to make a functioning 2D scroller, so I&#8217;m going to described how I got it to work.</p>
<p>First of all, the answer to the above question is you move the layer. If you follow the examples in the cocos2d download, you have a &#8220;GameScene&#8221; and a &#8220;GameLayer&#8221;. Well, everything that needs to be moved when your game scrolls should be added as a child to that GameLayer. If you are using a TileMap as a background, this includes that tilemap. The only thing that you don&#8217;t add as a child to the GameLayer is stuff that does not move with the scrolling view, such as your HUDLayer that has text that shows your characters health. Other than that, your character, the background, other characters, should all be added to the GameLayer.</p>
<p>You have to remember which objects are absolute (attached to your GameScene or other layers) versus those that are relative (a child of your GameLayer) when you set up your touch handling code. For my HUD that has buttons you can press at any time, say to pause the game, you want to add the touch handling object to your GameScene or HUDLayer class, since it doesn&#8217;t move. But if you want to be able to touch objects that scroll along with your view in the game itself, your touch handling code needs to be in an object that is a child of your GameLayer.</p>
<p>This might be a little confusing, so let&#8217;s see some code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">	gameLayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>GameLayer node<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>gameScene addChild<span style="color: #002200;">:</span>gameLayer z<span style="color: #002200;">:</span>zOrder_GameLayer<span style="color: #002200;">&#93;</span>;
&nbsp;
	hudLayer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>HUDLayer node<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>gameScene addChild<span style="color: #002200;">:</span>hudLayer z<span style="color: #002200;">:</span>zOrder_HudLayer<span style="color: #002200;">&#93;</span>;
&nbsp;
	tileMap <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>BGTileMap node<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>gameLayer addChild<span style="color: #002200;">:</span>tileMap z<span style="color: #002200;">:-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>gameScene addChild<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>PauseGameButton node<span style="color: #002200;">&#93;</span> z<span style="color: #002200;">:</span>zOrder_GameButtons<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>gameLayer addChild<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>FireGunAtTouchPoint node<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>The pause game button is always on your screen, while the point at which your character fires the gun depends on how how far your view has been scrolled (by moving GameLayer).</p>
<p>Let&#8217;s see some of the code that actually moves this game layer:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setViewpointCenter<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>point <span style="color: #002200;">&#123;</span>
	CGPoint centerPoint <span style="color: #002200;">=</span> ccp<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">240</span>, <span style="color: #2400d9;">160</span><span style="color: #002200;">&#41;</span>;
	viewPoint <span style="color: #002200;">=</span> ccpSub<span style="color: #002200;">&#40;</span>centerPoint, point<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// dont scroll so far so we see anywhere outside the visible map which would show up as black bars</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>point.x <span style="color: #002200;">&amp;</span>lt; centerPoint.x<span style="color: #002200;">&#41;</span>
		viewPoint.x <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>point.y <span style="color: #002200;">&amp;</span>lt; centerPoint.y<span style="color: #002200;">&#41;</span>
		viewPoint.y <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// while zoomed out, don't adjust the viewpoint</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>isZoomedOut<span style="color: #002200;">&#41;</span>
		gameLayer.position <span style="color: #002200;">=</span> viewPoint;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>When do you call that method? Well, it depends on what you want, but generally these scrolling games follow around the movement of your &#8216;main&#8217; character, right? So whatever character the you want to follow, add this to override the standard CocosNode setPosition method so you update your viewpoint whenever the character moves</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>point <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>StandardGameController sharedSingleton<span style="color: #002200;">&#93;</span> setViewpointCenter<span style="color: #002200;">:</span>point<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>super setPosition<span style="color: #002200;">:</span>point<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Note that the StandardGameController is a construct of mine that I use to separate the game logic out from the display code. It doesn&#8217;t matter exactly how you do it, you just need a way to have your main character object call back to something that contains a reference to GameLayer so it can adjust the position of your GameLayer.</p>
<p>Now remember, for your background to scroll properly, you need to add your background tileMap as a child of your GameLayer that is being moved around.</p>
<p>That being said, I found that an important method was missing from the cocos2d tilemap that I need to use in order to detect collisions based on the types of tiles encountered. I created a subclass of TMXTiledMap and added in these methods:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>coordinatesAtPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>point <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> ccp<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>point.x <span style="color: #002200;">/</span> self.tileSize.width<span style="color: #002200;">&#41;</span>, <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>self.mapSize.height <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>point.y <span style="color: #002200;">/</span> self.tileSize.height<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>getGIDAtPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>point <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>layer tileGIDAt<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>self coordinatesAtPosition<span style="color: #002200;">:</span>point<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>That way it&#8217;s easy to figure out what tile any individual object is colliding with. For example, in my main character object I can have code that runs in step: function with this:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">	BGTileMap<span style="color: #002200;">*</span> tileMap <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>StandardGameController sharedSingleton<span style="color: #002200;">&#93;</span>.tileMap;
	CGPoint coordinate <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tileMap coordinatesAtPosition<span style="color: #002200;">:</span>self.position<span style="color: #002200;">&#93;</span>;
	BBLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Right now on tile %d&quot;</span>,<span style="color: #002200;">&#91;</span>tileMap.layer tileGIDAt<span style="color: #002200;">:</span>coordinate<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</pre></div></div>

<p>Now I know what type of tile I am overlapping, and I can respond to the environment accordingly.</p>
<p>This is really all the code that you need to make a scrolling game view&#8230;I think some people overthink it and try adjusting the position of every object individually with some offset, but it&#8217;s not necessary since your objects can use relative positions with their parent.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1151609318119170";
/* 468x60, created 3/31/10 */
google_ad_slot = "7808045430";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>I have one last bit of code to add, and this is something kind of fun. It&#8217;s not complete, but at least it&#8217;s a start. What this allows you to do is &#8216;zoom out&#8217; so you can see your entire map with ALL the objects shrunk down, and then zoom back in to your character. The only tricky part is when you zoom back in, you have to slowly adjust your viewpoint in steps so the zoom in action is centered on your character, instead of jumping at the end.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#define ZOOM_BACK_IN_INTERVALS 10</span>
<span style="color: #6e371a;">#define ZOOM_OUT_RATE 0.3</span>
<span style="color: #11740a; font-style: italic;">// TODO need to refine this so for each step it uses the new viewpoint</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setZoom<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>zoomedIn <span style="color: #002200;">&#123;</span>
	BBLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Zooming in %d&quot;</span>, zoomedIn<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// this scales it out so the whole height of the tilemap is in the screen</span>
	<span style="color: #a61390;">float</span> zoomScaleFactor <span style="color: #002200;">=</span> <span style="color: #2400d9;">320</span> <span style="color: #002200;">/</span> <span style="color: #002200;">&#40;</span>tileMap.mapSize.height <span style="color: #002200;">*</span> tileMap.tileSize.height<span style="color: #002200;">&#41;</span>;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>zoomedIn<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>gameLayer runAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>ScaleTo actionWithDuration<span style="color: #002200;">:</span>ZOOM_OUT_RATE scale<span style="color: #002200;">:</span><span style="color: #2400d9;">1.0</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>gameLayer runAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>MoveTo actionWithDuration<span style="color: #002200;">:</span>ZOOM_OUT_RATE position<span style="color: #002200;">:</span>viewPoint<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>self schedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>setZoomedBackIn<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> interval<span style="color: #002200;">:</span>ZOOM_OUT_RATE<span style="color: #002200;">&#93;</span>; <span style="color: #11740a; font-style: italic;">// need this for the transistion</span>
	<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>gameLayer runAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>ScaleTo actionWithDuration<span style="color: #002200;">:</span>ZOOM_OUT_RATE scale<span style="color: #002200;">:</span>zoomScaleFactor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>gameLayer runAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>MoveTo actionWithDuration<span style="color: #002200;">:</span>ZOOM_OUT_RATE position<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;">&#93;</span>;
		isZoomedOut <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// need this small correction at the end to account of the player is moving and the viewpoint has changed to avoid jitter</span>
<span style="color: #6e371a;">#define ZOOM_OUT_CORRECTION_RATE 0.3</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setZoomedBackIn<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>ccTime<span style="color: #002200;">&#41;</span>dt <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self unschedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>setZoomedBackIn<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>gameLayer runAction<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>MoveTo actionWithDuration<span style="color: #002200;">:</span>ZOOM_OUT_CORRECTION_RATE position<span style="color: #002200;">:</span>viewPoint<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>self schedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>setZoomedBackInFinished<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> interval<span style="color: #002200;">:</span>ZOOM_OUT_CORRECTION_RATE<span style="color: #002200;">&#93;</span>; <span style="color: #11740a; font-style: italic;">// need this for the transistion</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setZoomedBackInFinished<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>ccTime<span style="color: #002200;">&#41;</span>dt <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self unschedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>setZoomedBackInFinished<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	isZoomedOut <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Now you see why my viewPoint variable was a class member&#8230;you&#8217;ll need it for these methods to work.</p>
<p>The reason this code isn&#8217;t complete is when it starts zooming in, it creates the actions to zoom in on the current viewpoint, but if the player is moving by the time the zoom animation is done, that viewpoint is changed and needs to &#8217;snap&#8217; to the new viewpoint. That is the reason for the setZoomedBackIn: method, which really shouldn&#8217;t have to move the gameLayer anymore. However, I haven&#8217;t yet written the code to continuously create smaller move actions to take into account a moving viewpoint as the animation continues, but doing so shouldn&#8217;t be that hard. If you want to see that bit when I finish, post in the comments and I&#8217;ll add it in.</p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/VkcE-Xqa4_Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/10/2d-scrolling-game-with-cocos2d-tilemap-with-zoom/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/10/2d-scrolling-game-with-cocos2d-tilemap-with-zoom/</feedburner:origLink></item>
		<item>
		<title>Using Box2D Physics Engine with Cocos2D iPhone</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/14U6YxSR-fY/</link>
		<comments>http://johnehartzog.com/2009/07/using-box2d-physics-engine-with-cocos2d-iphone/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 03:47:55 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[cocos2d iPhone]]></category>
		<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=381</guid>
		<description><![CDATA[Starting work on my new project, I&#8217;ve found Box2D to be a far superior physics engine than chipmunk. It is more mature, the API more flexible, and it seems to even perform faster. However, the cocos2d code for it was rather space, so here is a sort of helper file I had to create to [...]]]></description>
			<content:encoded><![CDATA[<p>Starting work on my new project, I&#8217;ve found Box2D to be a far superior physics engine than chipmunk. It is more mature, the API more flexible, and it seems to even perform faster. However, the cocos2d code for it was rather space, so here is a sort of helper file I had to create to make it work with my game.</p>
<p>Keep in mind this game is in progress and I&#8217;ve only been using this for a few days, so it may have issues that might pop up later on. It seems to be working very well for now though, with 40-50 objects on screen moving around with ~40 FPS.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1151609318119170";
/* 468x60, created 3/31/10 */
google_ad_slot = "7808045430";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Here is the header</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;">//  Box2DEngine.h</span>
<span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  Created by EricH on 7/22/09.</span>
<span style="color: #11740a; font-style: italic;">//  Copyright 2009 __MyCompanyName__. All rights reserved.</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;Box2D.h&quot;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// made this an extern constant to avoid obj c lookup overhead</span>
<span style="color: #a61390;">extern</span> b2World <span style="color: #002200;">*</span>bb_world;
&nbsp;
<span style="color: #a61390;">@interface</span> Box2DEngine <span style="color: #002200;">:</span> CocosNode <span style="color: #002200;">&#123;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>Box2DEngine <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sharedSingleton;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>createWorld<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGSize<span style="color: #002200;">&#41;</span>size;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>deleteWorld;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>runSimulation;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><script type="text/javascript"><!--
google_ad_client = "pub-1151609318119170";
/* 468x60, created 3/31/10 */
google_ad_slot = "7808045430";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The .mm file</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;">//  Box2DEngine.mm</span>
<span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  Created by EricH on 7/22/09.</span>
<span style="color: #11740a; font-style: italic;">//  Copyright 2009 __MyCompanyName__. All rights reserved.</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;HookActor.h&quot;</span>
&nbsp;
&nbsp;
<span style="color: #6e371a;">#import &quot;Box2DEngine.h&quot;</span>
<span style="color: #6e371a;">#import &quot;SuperBox2DActor.h&quot;</span>
&nbsp;
b2World<span style="color: #002200;">*</span> bb_world;
&nbsp;
<span style="color: #a61390;">const</span> float32 timeStep <span style="color: #002200;">=</span> 1.0f <span style="color: #002200;">/</span> 60.0f;
<span style="color: #a61390;">const</span> int32 velocityIterations <span style="color: #002200;">=</span> <span style="color: #2400d9;">10</span>;
<span style="color: #a61390;">const</span> int32 positionIterations <span style="color: #002200;">=</span> <span style="color: #2400d9;">10</span>;
&nbsp;
<span style="color: #6e371a;">#define MAX_NUM_COLLISIONS 2048 // TODO make sure this buffer is the right size</span>
b2ContactResult contactResultCache<span style="color: #002200;">&#91;</span>MAX_NUM_COLLISIONS<span style="color: #002200;">&#93;</span>;
int32 contactResultCount <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
class MyContactListener <span style="color: #002200;">:</span> public b2ContactListener <span style="color: #002200;">&#123;</span>
public<span style="color: #002200;">:</span>
	<span style="color: #a61390;">void</span> Add<span style="color: #002200;">&#40;</span><span style="color: #a61390;">const</span> b2ContactPoint<span style="color: #002200;">*</span> point<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">void</span> Persist<span style="color: #002200;">&#40;</span><span style="color: #a61390;">const</span> b2ContactPoint<span style="color: #002200;">*</span> point<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">void</span> Remove<span style="color: #002200;">&#40;</span><span style="color: #a61390;">const</span> b2ContactPoint<span style="color: #002200;">*</span> point<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">void</span> Result<span style="color: #002200;">&#40;</span><span style="color: #a61390;">const</span> b2ContactResult<span style="color: #002200;">*</span> point<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">// TODO we are making a deep copy of every contact point here</span>
		<span style="color: #11740a; font-style: italic;">// check the box2d contact masks to make sure we minimize unwanted contact results</span>
		contactResultCache<span style="color: #002200;">&#91;</span>contactResultCount<span style="color: #002200;">++</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #002200;">*</span>point; 
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>;
&nbsp;
<span style="color: #a61390;">void</span> handleCachedContactResults<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	b2ContactResult contactResult;
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i &lt; contactResultCount; i<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
<span style="color: #6e371a;">#ifdef BBDEBUG</span>
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>contactResultCount &gt;<span style="color: #002200;">=</span> MAX_NUM_COLLISIONS<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;RAN OUT OF BUFFER&quot;</span><span style="color: #002200;">&#41;</span>;
			<span style="color: #a61390;">assert</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span>
<span style="color: #6e371a;">#endif</span>
		contactResult <span style="color: #002200;">=</span> contactResultCache<span style="color: #002200;">&#91;</span>i<span style="color: #002200;">&#93;</span>;
		SuperBox2DActor<span style="color: #002200;">*</span> actorOne <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>SuperBox2DActor<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>contactResult.shape1<span style="color: #002200;">-</span>&gt;GetBody<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">-</span>&gt;GetUserData<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
		SuperBox2DActor<span style="color: #002200;">*</span> actorTwo <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>SuperBox2DActor<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>contactResult.shape2<span style="color: #002200;">-</span>&gt;GetBody<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">-</span>&gt;GetUserData<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>actorOne.isDead <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">!</span>actorTwo.isDead<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #002200;">&#91;</span>actorOne collisionResultOne<span style="color: #002200;">:&amp;</span>contactResult withActor<span style="color: #002200;">:</span>actorTwo<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#91;</span>actorTwo collisionResultTwo<span style="color: #002200;">:&amp;</span>contactResult withActor<span style="color: #002200;">:</span>actorOne<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">// clear the collision cache</span>
	contactResultCount <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">void</span> removeDeadActors<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	b2Body<span style="color: #002200;">*</span> node <span style="color: #002200;">=</span> bb_world<span style="color: #002200;">-</span>&gt;GetBodyList<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span>node<span style="color: #002200;">&#41;</span>	<span style="color: #002200;">&#123;</span>
		b2Body<span style="color: #002200;">*</span> b <span style="color: #002200;">=</span> node;
		node <span style="color: #002200;">=</span> node<span style="color: #002200;">-</span>&gt;GetNext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
		SuperBox2DActor<span style="color: #002200;">*</span> actor <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>SuperBox2DActor<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>b<span style="color: #002200;">-</span>&gt;GetUserData<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>actor.isDead<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
			<span style="color: #11740a; font-style: italic;">// remove from physics  engine</span>
			bb_world<span style="color: #002200;">-</span>&gt;DestroyBody<span style="color: #002200;">&#40;</span>b<span style="color: #002200;">&#41;</span>;
&nbsp;
			<span style="color: #11740a; font-style: italic;">// remove from game engine (cocos2d)</span>
			<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>StandardGameController sharedSingleton<span style="color: #002200;">&#93;</span> removeGameActor<span style="color: #002200;">:</span>actor<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #a61390;">@implementation</span> Box2DEngine
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>Box2DEngine<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sharedSingleton <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">static</span> Box2DEngine<span style="color: #002200;">*</span> sharedSingleton;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>sharedSingleton<span style="color: #002200;">&#41;</span>
		sharedSingleton <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Box2DEngine alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">return</span> sharedSingleton;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>createWorld<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGSize<span style="color: #002200;">&#41;</span>size <span style="color: #002200;">&#123;</span>
	b2AABB worldAABB;
	worldAABB.lowerBound.Set<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;
	worldAABB.upperBound.Set<span style="color: #002200;">&#40;</span>size.width <span style="color: #002200;">*</span> BOX2D_SCALE_FACTOR_INVERSE, size.height <span style="color: #002200;">*</span> BOX2D_SCALE_FACTOR_INVERSE<span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// TODO this shouldnt be inverse?</span>
&nbsp;
	b2Vec2 gravity<span style="color: #002200;">&#40;</span>0.0f, <span style="color: #002200;">-</span>30.0f<span style="color: #002200;">&#41;</span>;
	bool doSleep <span style="color: #002200;">=</span> <span style="color: #a61390;">true</span>;
&nbsp;
	bb_world <span style="color: #002200;">=</span> new b2World<span style="color: #002200;">&#40;</span>worldAABB, gravity, doSleep<span style="color: #002200;">&#41;</span>;
	bb_world<span style="color: #002200;">-</span>&gt;SetContactListener<span style="color: #002200;">&#40;</span>new MyContactListener<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>deleteWorld <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self unschedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>step<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	delete bb_world;
	bb_world <span style="color: #002200;">=</span> <span style="color: #a61390;">NULL</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>runSimulation <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self schedule<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>step<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>step<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>ccTime<span style="color: #002200;">&#41;</span>dt <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">// step the world</span>
	bb_world<span style="color: #002200;">-</span>&gt;Step<span style="color: #002200;">&#40;</span>dt, velocityIterations, positionIterations<span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// TODO do i use timestep or dt here?</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">//BBLog(@&quot;Num of contact results is %d&quot;,contactResultCount);</span>
	<span style="color: #11740a; font-style: italic;">// do stuff with collisions</span>
	handleCachedContactResults<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// remove all actors that are marked as dead</span>
	removeDeadActors<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// update cocosnode positions</span>
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>b2Body<span style="color: #002200;">*</span> b <span style="color: #002200;">=</span> bb_world<span style="color: #002200;">-</span>&gt;GetBodyList<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; b; b <span style="color: #002200;">=</span> b<span style="color: #002200;">-</span>&gt;GetNext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>b<span style="color: #002200;">-</span>&gt;GetUserData<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">!=</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			SuperBox2DActor <span style="color: #002200;">*</span>actor <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>SuperBox2DActor<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>b<span style="color: #002200;">-</span>&gt;GetUserData<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
			b2Vec2 position <span style="color: #002200;">=</span> b<span style="color: #002200;">-</span>&gt;GetPosition<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
			actor.position <span style="color: #002200;">=</span> b2toCGPoint<span style="color: #002200;">&#40;</span>position<span style="color: #002200;">&#41;</span>;
			actor.rotation <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span> <span style="color: #002200;">*</span> CC_RADIANS_TO_DEGREES<span style="color: #002200;">&#40;</span>b<span style="color: #002200;">-</span>&gt;GetAngle<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
			<span style="color: #11740a; font-style: italic;">//NSLog(@&quot;obj %@ %4.2f %4.2f\n&quot;,actor, position.x, position.y);</span>
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><script type="text/javascript"><!--
google_ad_client = "pub-1151609318119170";
/* 468x60, created 3/31/10 */
google_ad_slot = "7808045430";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/14U6YxSR-fY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/07/using-box2d-physics-engine-with-cocos2d-iphone/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/07/using-box2d-physics-engine-with-cocos2d-iphone/</feedburner:origLink></item>
		<item>
		<title>StickWars 1.5 Live after nearly a Month</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/fWKSjWuC6H0/</link>
		<comments>http://johnehartzog.com/2009/06/stickwars-1-5-live-after-nearly-a-month/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 14:52:03 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[StickWars]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=376</guid>
		<description><![CDATA[After nearly a month of delay, StickWars 1.5 is live with important bug fixes and a few new features, including a few achievements. Luckily I&#8217;m all ready to push out v1.6 which includes a new boss enemy, the giant stick figure. I also added a lot of small fun features, so as the ability to [...]]]></description>
			<content:encoded><![CDATA[<p>After nearly a month of delay, StickWars 1.5 is live with important bug fixes and a few new features, including a few achievements. Luckily I&#8217;m all ready to push out v1.6 which includes a new boss enemy, the giant stick figure. I also added a lot of small fun features, so as the ability to throw and slam stick figures into one another to kill them. You can also now kill the more powerful enemies by slamming many small stick figures into them. I think this adds yet another way for talented players to save money and reach higher levels and scores <img src='http://johnehartzog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>In addition, I&#8217;ve re-written parts of the code for the basic functions behind levels and sound, and somehow I managed to fix a bug that I didn&#8217;t know existed. The game no longer crashes sometimes when you attempt to load a new level&#8211;the bug before was due to my background sound engine, except none of my debugging tools had located it there. Basically the last crash bug has been fixed, and since I&#8217;ve been adding features to this version for the past week I have not seen it crash once. I&#8217;m really proud of the stability of the game now.</p>
<p>There is a new loading screen that I&#8217;m particularly proud of&#8211;it allows me to include short hints that answer the most common questions I get from users based on reviews, emails, and forum posts. It&#8217;s a lot nicer to be able to read a short hint while you are waiting 3-6 seconds for the level to load, and maybe help out your gameplay, rather then just looking at the word &#8216;loading&#8217; over your current screen. I can also throw in a few words about upcoming versions, such as my brief request for feedback about charging in game $0.99 for the new multi-player challenges coming in the next version. I&#8217;d love to get some player feedback on this&#8211;I feel most people are happy paying only $0.99 for StickWars, and I don&#8217;t want to raise the price for the same basic game (campaign mode), but these multi-player challenges are a whole new ballpark that I feel deserves another $0.99. However, I&#8217;m willing to listen to my users who feel strongly enough about this to contact me. I will be providing a few of the challenges free so a player can test them out.</p>
<p>The bad news is StickWars has fallen off the top 10 for the first time since it first rose up there in April. But sitting at #11, I&#8217;m hoping these new features and fixes will bring new life back to the game and drive more players to it.</p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/fWKSjWuC6H0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/06/stickwars-1-5-live-after-nearly-a-month/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/06/stickwars-1-5-live-after-nearly-a-month/</feedburner:origLink></item>
		<item>
		<title>StickWars in the News – First Adoptor of OpenFeint 2.1 OS 3.0 Features</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/7HM6kz7DRVI/</link>
		<comments>http://johnehartzog.com/2009/06/stickwars-in-the-news-first-adoptor-of-openfeint-2-1-os-3-0-features/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 21:52:30 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[StickWars]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=371</guid>
		<description><![CDATA[One of the many articles is up at marketwire.com. Here is my blurb:
Eric Hartzog, StickWars: &#8220;StickWars will include a new gameplay mode that will allow a player to battle for a limited period of time and challenge his friends for top scores. His friends will be notified of the challenge through push notifications, powered by [...]]]></description>
			<content:encoded><![CDATA[<p>One of the many articles is up at <a href="http://www.marketwire.com/press-release/Openfeint-1005074.html">marketwire.com</a>. Here is my blurb:</p>
<blockquote><p>Eric Hartzog, StickWars: &#8220;StickWars will include a new gameplay mode that will allow a player to battle for a limited period of time and challenge his friends for top scores. His friends will be notified of the challenge through push notifications, powered by OpenFeint, and they will be able to easily load StickWars and respond to the challenge. These challenges will flow back and forth in near real-time, and be easily visible to players even if StickWars is not currently loaded.</p>
<p>A single-player game inevitably has a limited amount of engagement &#8212; developers can only add so much content to a game. But by drawing from existing social networks and encouraging social competition between gamers, the players themselves create new tasks for one another and new obstacles to overcome. This user-generated content expands the value of any game far beyond what was initially put into it, and continues to expand as the popularity of the game increases even further.&#8221; </p></blockquote>
<p>You can read more details about exactly what this means for StickWars in this <a href="http://johnehartzog.com/forums/showthread.php?t=421">forum post</a>. There are a lot of new features and brand new game modes coming to StickWars. These new features will require a small purchase in game, but give access to many social features that allow you to compete against your friends in many different challenges.</p>
<p>Expect these features ready at the start of July, and for them to be live anywhere between 1-4 weeks after that when Apple approves it.</p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/7HM6kz7DRVI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/06/stickwars-in-the-news-first-adoptor-of-openfeint-2-1-os-3-0-features/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/06/stickwars-in-the-news-first-adoptor-of-openfeint-2-1-os-3-0-features/</feedburner:origLink></item>
		<item>
		<title>Create multi-line labels with cocos 2d iphone</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/tHc-Cm1cnIM/</link>
		<comments>http://johnehartzog.com/2009/06/create-multi-line-labels-with-cocos-2d-iphone/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 20:03:18 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[cocos2d iPhone]]></category>
		<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=363</guid>
		<description><![CDATA[Update: This code is obsolete now. You can just do

Label *messageLabel = &#91;Label labelWithString:message dimensions:CGSizeMake&#40;380, 120&#41; alignment:UITextAlignmentCenter fontName:@&#34;your_custom_font&#34; fontSize:26&#93;;

 by using the new FontManager class. For example, run this once in your app delegate when your program first loads

&#91;&#91;FontManager sharedManager&#93; loadFont:@&#34;your_custom_font&#34;&#93;;

It can take a long NSString and create multiple labels without breaking up a word. [...]]]></description>
			<content:encoded><![CDATA[<p>Update: This code is obsolete now. You can just do</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">Label <span style="color: #002200;">*</span>messageLabel <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>Label labelWithString<span style="color: #002200;">:</span>message dimensions<span style="color: #002200;">:</span>CGSizeMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">380</span>, <span style="color: #2400d9;">120</span><span style="color: #002200;">&#41;</span> alignment<span style="color: #002200;">:</span>UITextAlignmentCenter fontName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;your_custom_font&quot;</span> fontSize<span style="color: #002200;">:</span><span style="color: #2400d9;">26</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p> by using the new FontManager class. For example, run this once in your app delegate when your program first loads</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>FontManager sharedManager<span style="color: #002200;">&#93;</span> loadFont<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;your_custom_font&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>It can take a long NSString and create multiple labels without breaking up a word. I&#8217;ll eventually use this for my help screen, replacing the current 6 different 480&#215;320 png images that I load for each one <img src='http://johnehartzog.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>The code is simple, but hopefully it might save somebody the time it took me to write it. I had to look up some very basic elements of ObjC here, so if there is a much easier way to do this, please let me know but don&#8217;t make too much fun of me.</p>
<p>You can easily switch out the BitmapFontAtlas for just a normal Label and it would work just fine.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setTipString<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>str <span style="color: #002200;">&#123;</span>
&nbsp;
	NSInteger lineChars <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
	<span style="color: #a61390;">BOOL</span> isSpace <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
	NSInteger index <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
	NSInteger numLines <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
	<span style="color: #400080;">NSMutableString</span> <span style="color: #002200;">*</span>line <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableString</span> stringWithCapacity<span style="color: #002200;">:</span>LINE_LENGTH<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span>index &lt;<span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>str length<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>index <span style="color: #002200;">==</span> <span style="color: #002200;">&#91;</span>str length<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			BitmapFontAtlas <span style="color: #002200;">*</span>tip <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>BitmapFontAtlas bitmapFontAtlasWithString<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithString<span style="color: #002200;">:</span>line<span style="color: #002200;">&#93;</span> 
																																 fntFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;text.fnt&quot;</span>
																															 alignment<span style="color: #002200;">:</span>UITextAlignmentLeft<span style="color: #002200;">&#93;</span> 
															retain<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#91;</span>tip setPosition<span style="color: #002200;">:</span> cpv<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">30</span>,<span style="color: #2400d9;">210</span> <span style="color: #002200;">-</span> <span style="color: #2400d9;">20</span> <span style="color: #002200;">*</span> numLines<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>tip<span style="color: #002200;">&#93;</span>;	
			<span style="color: #a61390;">return</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
&nbsp;
		<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>tmp <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>str substringWithRange<span style="color: #002200;">:</span>NSMakeRange<span style="color: #002200;">&#40;</span>index, <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>line appendString<span style="color: #002200;">:</span>tmp<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>tmp isEqual<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; &quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
			isSpace <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
		<span style="color: #a61390;">else</span>
			isSpace <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>lineChars &gt;<span style="color: #002200;">=</span> LINE_LENGTH <span style="color: #002200;">&amp;&amp;</span> isSpace<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			BitmapFontAtlas <span style="color: #002200;">*</span>tip <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>BitmapFontAtlas bitmapFontAtlasWithString<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithString<span style="color: #002200;">:</span>line<span style="color: #002200;">&#93;</span> 
																																 fntFile<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;text.fnt&quot;</span>
																															 alignment<span style="color: #002200;">:</span>UITextAlignmentLeft<span style="color: #002200;">&#93;</span> 
															retain<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#91;</span>tip setPosition<span style="color: #002200;">:</span> cpv<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">30</span>,<span style="color: #2400d9;">210</span> <span style="color: #002200;">-</span> <span style="color: #2400d9;">20</span> <span style="color: #002200;">*</span> numLines<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>tip<span style="color: #002200;">&#93;</span>;	
			lineChars <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>;
			<span style="color: #002200;">&#91;</span>line setString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span><span style="color: #002200;">&#93;</span>;
			numLines<span style="color: #002200;">++</span>;
		<span style="color: #002200;">&#125;</span>
		lineChars<span style="color: #002200;">++</span>;
		index<span style="color: #002200;">++</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/tHc-Cm1cnIM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/06/create-multi-line-labels-with-cocos-2d-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/06/create-multi-line-labels-with-cocos-2d-iphone/</feedburner:origLink></item>
		<item>
		<title>The Developer-Friendly AppStore</title>
		<link>http://feedproxy.google.com/~r/Johnnyworks/~3/F0GCqpoH9Uk/</link>
		<comments>http://johnehartzog.com/2009/06/the-developer-friendly-appstore/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 17:04:31 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Distribution]]></category>
		<category><![CDATA[StickWars]]></category>

		<guid isPermaLink="false">http://johnehartzog.com/?p=348</guid>
		<description><![CDATA[Lacking a better medium to communicate to all my users how difficult Apple is making it to provide them with the level of service I&#8217;d want to,  I&#8217;ll get my rant out here on my blog where it&#8217;s safe.
I had a bugfix version of StickWars ready the same day the buggy version 1.4 was released. [...]]]></description>
			<content:encoded><![CDATA[<p>Lacking a better medium to communicate to all my users how difficult Apple is making it to provide them with the level of service I&#8217;d want to,  I&#8217;ll get my rant out here on my blog where it&#8217;s safe.</p>
<p>I had a bugfix version of StickWars ready the same day the buggy version 1.4 was released. That day was May 27th. Is is June 18th and I&#8217;m still waiting patiently for Apple take a look at the update. It has been two weeks since I submitted a corrected update, and I haven&#8217;t got a lick of feedback back. In the mean time, my app has dropped from #3 to #9, and my users are sitting there wondering what I&#8217;m doing when in fact I have two more full-content updates ready for release, completed in the time it took Apple to approve a bugfix release. Keep in mind that my app has been in the top 10 paid apps for months now&#8211;this is one of Apple&#8217;s moneymaking apps. I would think they would want to work quickly to approve an update which would improve the game experience for hundreds of thousands of players.</p>
<p>Now I am not absolving myself of the responsibility of releasing a version with some problems. The fault for that lies solely on me, and was due to a somewhat chaotic situation as I was moving homes and starting a new full-time job that led to me not having as much time as I expected to test the release. This is no excuse, however, as I should have just rejected the update and resubmitted later after more testing. But the problem was magnified greatly by the simple fact that Apple has no agreement or desire to protect the ability of developers to have control over the applications they are producing. We can&#8217;t respond directly to user complaints or support requests posted on the AppStore. Most importantly, our update schedule is 100% subject to the whims and scheduling of Apple, so an update that we kill ourselves to complete on a rapid basis could be live in 3 days, or in 30. And we never know what to expect until after the fact.</p>
<p>Before a couple weeks ago when Apple first started emailing me to let me know that they approved my update, do you know how I would find out my update was live? My as-it-happens google alert would send me an email that a new cracked version of StickWars was available on some blog somewhere. I also rely 100% on third-party tools to tell me how people are responding to my applications. Check out <a href="http://www.appfigures.com" target="_blank">www.appfigures.com</a> to see what I&#8217;m talking about&#8211;from that site, you can read reviews from all countries. I received a lot of valueable feedback reading through the reviews of other english-speaking nations. Apple provides no way (that I know of) for developers to see the status of their application in the AppStore (if it is featured anywhere, it&#8217;s rank in other countries, etc&#8230;).</p>
<p>In addition, I&#8217;ve only received two of the seven payments for April 2009 that I should have been paid by now. Granted, one of those received was from the US, and therefore was the largest one, but they are sitting there wasting interest on a lot money and I still have not recieved a single response as to why. Three weeks ago I dug through their contact form and sent a polite email asking them why I got the financial report for a few thousands but never received the deposit, but I have yet to receive even as much as an automated reply confirming receipt of my message. I have sent more inquries weekly, and just started sending them to a more broad range of email address, and will update this at some point when I get a response.</p>
<p>Don&#8217;t get me wrong, I think Apple has done an amazing job with the AppStore, and building a system like this from scratch is bound to be difficult, with problems like this sprouting up and slowly being fixed month by month. But right now, I seem to find myself trapped at a criticial point, where if another week goes by without Apple looking at my update and StickWars drops off the top 10, and then the many more features and improvements I&#8217;ve made in the meantime won&#8217;t matter as all the exposure in the AppStore revolves around the top 10 and top 100 lists. I understand that applications have a limited shelf life at the top of the lists, but I didn&#8217;t expect mine to be cut short at the end by random and unpredictable update approval practices by the iTunes Store.</p>
<p>I believe that complaining without recommending a course of action to fix the problem is a waste of words, so here are some ideas that I would love to see put into the AppStore.</p>
<ul>
<li>A priority queue for update approval based on popularity. The apps that are getting constant updates pushed out to hundreds of thousands of players should have more personal attention from Apple staffers. On the other hand, it should be balanced so that even an unpopular app which has gone two weeks with an update in the queue is bumped up to the top priority.</li>
<li>A developer portal into iTunes Store &#8220;Insights&#8221; that gives you access to any information related to the status of your applications, including reviews and rankings (in all categories) from all nations, along with any places where the application is featured.</li>
<li>More analytic information, so I can see how many users download my Lite version first, and then download the Paid version.</li>
<li>Allow developers to post short &#8216;responses&#8217; to user reviews. This way, when somebody complains &#8220;the game was too easy wish i could make it harder!!@#&#8221; a developer who cares can go through and add a response such as &#8220;just hit the options button and set the difficulty to hard&#8221; (real example).</li>
</ul>
<p>Update: I did eventually get paid by Apple like 1 or 2 months late, and about 2 weeks after I got paid I got responses to my multiple emails (sent over a month before) saying &#8220;we show your account as paid in full&#8230;&#8221;. To be fair to Apple, my banking situation was a little complex and I understand that it takes time to go through all that, but I would have appreciated a brief response (or even an automated confirmation) to my inquiries long before almost 2 months have gone by.</p>
<img src="http://feeds.feedburner.com/~r/Johnnyworks/~4/F0GCqpoH9Uk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://johnehartzog.com/2009/06/the-developer-friendly-appstore/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://johnehartzog.com/2009/06/the-developer-friendly-appstore/</feedburner:origLink></item>
	</channel>
</rss>
