<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: iPhone Game Programming &#8211; Tutorial 5 &#8211; Animation Class</title>
	<atom:link href="http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/</link>
	<description>iPhone Game Development - Web Development</description>
	<lastBuildDate>Wed, 28 Jul 2010 17:12:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Tweets that mention iPhone Game Programming – Tutorial 5 – Animation Class &#124; 71² - The ramblings of two 30-something developers -- Topsy.com</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-8/#comment-3227</link>
		<dc:creator>Tweets that mention iPhone Game Programming – Tutorial 5 – Animation Class &#124; 71² - The ramblings of two 30-something developers -- Topsy.com</dc:creator>
		<pubDate>Sun, 25 Apr 2010 00:43:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-3227</guid>
		<description>[...] This post was mentioned on Twitter by onion_papa. onion_papa said: http://tinyurl.com/29mbqpy iPhone Game Programming – Tutorial 5 – Animation Class &#124; 71² - The ... (WWW.71SQUARED.COM) [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by onion_papa. onion_papa said: <a href="http://tinyurl.com/29mbqpy" rel="nofollow">http://tinyurl.com/29mbqpy</a> iPhone Game Programming – Tutorial 5 – Animation Class | 71² &#8211; The &#8230; (WWW.71SQUARED.COM) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rob</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-8/#comment-3057</link>
		<dc:creator>rob</dc:creator>
		<pubDate>Sun, 11 Apr 2010 04:16:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-3057</guid>
		<description>Thanks Mike for the great tutorials! I am totally new to iPhone development and OpenGL ES and really appreciate being able to follow along and see how this works... I am doing something really simple (i think!) ... I just want to animate a figure running... 1 cycle in a continuous loop - i&#039;m thinking 60 frames - just looping through in one spot (character is not running across the screen). I got your animations to work fine (16x16px) BUT when i replace with my spritesheet character which is 320x320px the character doesn&#039;t appear at that size but rather about 4 small figures appear - they DO animate but why are they tiny and more than 1? (my scale factor is set at 1)... any ideas would be appreciated - is it to do with a texture altas file needing to be created at &quot;power of 2&quot;? ... don&#039;t quite understand that concept.

many thanks again, rob</description>
		<content:encoded><![CDATA[<p>Thanks Mike for the great tutorials! I am totally new to iPhone development and OpenGL ES and really appreciate being able to follow along and see how this works&#8230; I am doing something really simple (i think!) &#8230; I just want to animate a figure running&#8230; 1 cycle in a continuous loop &#8211; i&#8217;m thinking 60 frames &#8211; just looping through in one spot (character is not running across the screen). I got your animations to work fine (16x16px) BUT when i replace with my spritesheet character which is 320x320px the character doesn&#8217;t appear at that size but rather about 4 small figures appear &#8211; they DO animate but why are they tiny and more than 1? (my scale factor is set at 1)&#8230; any ideas would be appreciated &#8211; is it to do with a texture altas file needing to be created at &#8220;power of 2&#8243;? &#8230; don&#8217;t quite understand that concept.</p>
<p>many thanks again, rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danegraphics</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-8/#comment-3021</link>
		<dc:creator>Danegraphics</dc:creator>
		<pubDate>Mon, 05 Apr 2010 04:15:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-3021</guid>
		<description>Nevermind. I was incorrectly using delta.</description>
		<content:encoded><![CDATA[<p>Nevermind. I was incorrectly using delta.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danegraphics</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-8/#comment-3020</link>
		<dc:creator>Danegraphics</dc:creator>
		<pubDate>Mon, 05 Apr 2010 04:01:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-3020</guid>
		<description>sorry, the import and include are this:

#import Foundation/Foundation.h 
#include math.h</description>
		<content:encoded><![CDATA[<p>sorry, the import and include are this:</p>
<p>#import Foundation/Foundation.h<br />
#include math.h</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danegraphics</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-8/#comment-3019</link>
		<dc:creator>Danegraphics</dc:creator>
		<pubDate>Mon, 05 Apr 2010 03:55:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-3019</guid>
		<description>I&#039;m having problems defining a class. everything builds correctly but my init doesn&#039;t appear to assign anything a value.

Here&#039;s my *.h file:

----------------------
#import 
#include 


@interface Progression : NSObject {
	float currentValue;
	BOOL doesLoop;
	float loopBegin;
	float loopEnd;

}
@property (nonatomic)float currentValue;
@property (nonatomic)BOOL doesLoop;
@property (nonatomic)float loopBegin;
@property (nonatomic)float loopEnd;

-(id)initWithValue:(float)value doesLoop:(BOOL)loop loopBegin:(float)loopB loopEnd:(float)loopE;
-(void)progressBy:(float)value;

@end

-----------------------

and my *.m file:

-----------------------
#import &quot;Progression.h&quot;


@implementation Progression
@synthesize currentValue;
@synthesize doesLoop;
@synthesize loopBegin;
@synthesize loopEnd;

-(id)init {
	self = [super init];
	if(self != nil) {
		currentValue = 0;
		doesLoop = NO;
		loopBegin = 0;
		loopEnd = 1;
	}
	return self;
}

-(id)initWithValue:(float)value doesLoop:(BOOL)loop loopBegin:(float)loopB loopEnd:(float)loopE {
	self = [super init];
	if(self != nil) {
		currentValue = value;
		doesLoop = loop;
		loopBegin = loopB;
		loopEnd = loopE;
	}
	return self;
}


-(void)progressBy:(float)value {
	currentValue = currentValue + value;
	if(currentValue &gt; loopEnd) {
		currentValue = loopBegin + fmod(currentValue,loopEnd);
	}
}

@end
--------------------

Please help.</description>
		<content:encoded><![CDATA[<p>I&#8217;m having problems defining a class. everything builds correctly but my init doesn&#8217;t appear to assign anything a value.</p>
<p>Here&#8217;s my *.h file:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
#import<br />
#include </p>
<p>@interface Progression : NSObject {<br />
	float currentValue;<br />
	BOOL doesLoop;<br />
	float loopBegin;<br />
	float loopEnd;</p>
<p>}<br />
@property (nonatomic)float currentValue;<br />
@property (nonatomic)BOOL doesLoop;<br />
@property (nonatomic)float loopBegin;<br />
@property (nonatomic)float loopEnd;</p>
<p>-(id)initWithValue:(float)value doesLoop:(BOOL)loop loopBegin:(float)loopB loopEnd:(float)loopE;<br />
-(void)progressBy:(float)value;</p>
<p>@end</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>and my *.m file:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
#import &#8220;Progression.h&#8221;</p>
<p>@implementation Progression<br />
@synthesize currentValue;<br />
@synthesize doesLoop;<br />
@synthesize loopBegin;<br />
@synthesize loopEnd;</p>
<p>-(id)init {<br />
	self = [super init];<br />
	if(self != nil) {<br />
		currentValue = 0;<br />
		doesLoop = NO;<br />
		loopBegin = 0;<br />
		loopEnd = 1;<br />
	}<br />
	return self;<br />
}</p>
<p>-(id)initWithValue:(float)value doesLoop:(BOOL)loop loopBegin:(float)loopB loopEnd:(float)loopE {<br />
	self = [super init];<br />
	if(self != nil) {<br />
		currentValue = value;<br />
		doesLoop = loop;<br />
		loopBegin = loopB;<br />
		loopEnd = loopE;<br />
	}<br />
	return self;<br />
}</p>
<p>-(void)progressBy:(float)value {<br />
	currentValue = currentValue + value;<br />
	if(currentValue &gt; loopEnd) {<br />
		currentValue = loopBegin + fmod(currentValue,loopEnd);<br />
	}<br />
}</p>
<p>@end<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Please help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DonnaLea</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-8/#comment-3006</link>
		<dc:creator>DonnaLea</dc:creator>
		<pubDate>Thu, 01 Apr 2010 03:57:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-3006</guid>
		<description>Hi Mike,

I&#039;m having the same issue as Jason. And from what I can see, it is a binding issue. I think the reason is because in the Image renderAt method it is checking to see if the texture is already bound using your if statement:

&lt;code&gt;
	if([texture name] != appDelegate.currentTexture) {
		[appDelegate setCurrentTexture:[texture name]];
		glBindTexture(GL_TEXTURE_2D, [texture name]);
	}
&lt;/code&gt;

And then we jump to the font rendering for rendering the font, which just binds without checking if the texture is already bound as so:

&lt;code&gt;
	glBindTexture(GL_TEXTURE_2D, [[image texture] name]);
&lt;/code&gt;

and then when it goes back to the animation it uses the image render code, and according to the appdelegate, that texture is already bound, so it skips the binding step, except that when we did the font rendering, it changed the binding without telling the app delegate. 

What I can&#039;t figure out, is how come the code downloaded from the tutorial works, cos it has that flaw in it :P Cos in my code which I&#039;ve been changing as I follow the tutorial video it doesn&#039;t work with that flaw in it.... so I&#039;ve missed something somewhere. 

Cheers,
Donna</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>I&#8217;m having the same issue as Jason. And from what I can see, it is a binding issue. I think the reason is because in the Image renderAt method it is checking to see if the texture is already bound using your if statement:</p>
<div class="codesnip-container" >if([texture name] != appDelegate.currentTexture) {<br />
		[appDelegate setCurrentTexture:[texture name]];<br />
		glBindTexture(GL_TEXTURE_2D, [texture name]);<br />
	}</div>
<p>And then we jump to the font rendering for rendering the font, which just binds without checking if the texture is already bound as so:</p>
<div class="codesnip-container" >glBindTexture(GL_TEXTURE_2D, [[image texture] name]);</div>
<p>and then when it goes back to the animation it uses the image render code, and according to the appdelegate, that texture is already bound, so it skips the binding step, except that when we did the font rendering, it changed the binding without telling the app delegate. </p>
<p>What I can&#8217;t figure out, is how come the code downloaded from the tutorial works, cos it has that flaw in it :P Cos in my code which I&#8217;ve been changing as I follow the tutorial video it doesn&#8217;t work with that flaw in it&#8230;. so I&#8217;ve missed something somewhere. </p>
<p>Cheers,<br />
Donna</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-8/#comment-2849</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Tue, 09 Mar 2010 17:49:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-2849</guid>
		<description>Hi Jason, it sounds as though the font texture once bound is still being used for the animation, rather than the animation binding its own texture.  Have you checked to make sure that the Animation code actually binds to the right texture?

Are you caching the texture number and checking to see if its changed maybe before changing it.  It certainly sounds like a texture binding issue.

Let me know what you find.  If you can&#039;t see the problem and can send the project I&#039;ll try to take a look.

Mike</description>
		<content:encoded><![CDATA[<p>Hi Jason, it sounds as though the font texture once bound is still being used for the animation, rather than the animation binding its own texture.  Have you checked to make sure that the Animation code actually binds to the right texture?</p>
<p>Are you caching the texture number and checking to see if its changed maybe before changing it.  It certainly sounds like a texture binding issue.</p>
<p>Let me know what you find.  If you can&#8217;t see the problem and can send the project I&#8217;ll try to take a look.</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-7/#comment-2848</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 09 Mar 2010 17:45:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-2848</guid>
		<description>HI Mike,

Love the tutorials and am looking forward to buying your book!

I have taken the tutorial 5 code and made it so that glView is loaded by a glViewController that is loaded by a RootViewController that is loaded by the AppDelegate. The only thing I had to change in your code was the reference to the AppDelegate and the currentTexture variable which I put in my glViewController class. I call:

[glView performSelectorOnMainThread:@selector(mainGameLoop) withObject:nil waitUntilDone:NO];

from the glViewController.

When I run the app everything works great except that the animation is referencing the wrong sprite sheet. Instead of animating the explosion it is animating a small piece of the font texture the same size as the explosion.

What I have found is that if:

[font1 drawStringAt:CGPointMake(messageX, 200) text:message];

immediately precedes:

[anim renderAtPoint:CGPointMake(160, 200)];

Then I always have this problem. However if I put any other render call between the two, or if I call the font after the anim one then the problem goes away and the animation uses the correct sprite sheet.

I have built this app twice to make sure I wasn&#039;t accidentally changing any of your code. I have no warnings and no errors.

Can you think of any reason for this strange behaviour?</description>
		<content:encoded><![CDATA[<p>HI Mike,</p>
<p>Love the tutorials and am looking forward to buying your book!</p>
<p>I have taken the tutorial 5 code and made it so that glView is loaded by a glViewController that is loaded by a RootViewController that is loaded by the AppDelegate. The only thing I had to change in your code was the reference to the AppDelegate and the currentTexture variable which I put in my glViewController class. I call:</p>
<p>[glView performSelectorOnMainThread:@selector(mainGameLoop) withObject:nil waitUntilDone:NO];</p>
<p>from the glViewController.</p>
<p>When I run the app everything works great except that the animation is referencing the wrong sprite sheet. Instead of animating the explosion it is animating a small piece of the font texture the same size as the explosion.</p>
<p>What I have found is that if:</p>
<p>[font1 drawStringAt:CGPointMake(messageX, 200) text:message];</p>
<p>immediately precedes:</p>
<p>[anim renderAtPoint:CGPointMake(160, 200)];</p>
<p>Then I always have this problem. However if I put any other render call between the two, or if I call the font after the anim one then the problem goes away and the animation uses the correct sprite sheet.</p>
<p>I have built this app twice to make sure I wasn&#8217;t accidentally changing any of your code. I have no warnings and no errors.</p>
<p>Can you think of any reason for this strange behaviour?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-7/#comment-2738</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Sun, 21 Feb 2010 18:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-2738</guid>
		<description>Hi Mike,

Sometimes the answer to a question is so obvious that you miss it. Must be the alzheimers kicking in.

Just needed to check if the animation was running lmao now + feeling a little slow.</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>Sometimes the answer to a question is so obvious that you miss it. Must be the alzheimers kicking in.</p>
<p>Just needed to check if the animation was running lmao now + feeling a little slow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://www.71squared.com/2009/04/iphone-game-programming-tutorial-5-animation-class/comment-page-7/#comment-2737</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Sun, 21 Feb 2010 15:06:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=395#comment-2737</guid>
		<description>I think I&#039;m going to have to re-write the animation method to get it to do what I want as I thinking i&#039;m going to need more control than is provided in the current class.</description>
		<content:encoded><![CDATA[<p>I think I&#8217;m going to have to re-write the animation method to get it to do what I want as I thinking i&#8217;m going to need more control than is provided in the current class.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
