<?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 12 &#8211; Saving State</title>
	<atom:link href="http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/</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: Kaizoku</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-5/#comment-3762</link>
		<dc:creator>Kaizoku</dc:creator>
		<pubDate>Mon, 26 Jul 2010 05:18:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-3762</guid>
		<description>Thx mike, the project file seems to be only the joypad, not the actual tutorial 12 folder.</description>
		<content:encoded><![CDATA[<p>Thx mike, the project file seems to be only the joypad, not the actual tutorial 12 folder.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-5/#comment-3260</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Wed, 28 Apr 2010 13:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-3260</guid>
		<description>Hi Mike, thanks for all the tutorials.  Had a follow-up question similar to the one above me (dave).  Is there a way to restore a singleton (with state) or is it better practice to just save the data individually from the singleton, initialize and rebuild the singleton manually from my &quot;Load Game&quot; methods?</description>
		<content:encoded><![CDATA[<p>Hi Mike, thanks for all the tutorials.  Had a follow-up question similar to the one above me (dave).  Is there a way to restore a singleton (with state) or is it better practice to just save the data individually from the singleton, initialize and rebuild the singleton manually from my &#8220;Load Game&#8221; methods?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dave</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-5/#comment-3009</link>
		<dc:creator>dave</dc:creator>
		<pubDate>Fri, 02 Apr 2010 00:06:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-3009</guid>
		<description>Hi Mike,

Thanks for all the great tutorials. I just wanted to ask a question about saving game state. Given an earlier tutorial on a singleton shared game state, why not just centralise all game state and encode/decode/save the singleton object? Is there a benefit to having each game object know how to encode/decode its own game state data?

David</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>Thanks for all the great tutorials. I just wanted to ask a question about saving game state. Given an earlier tutorial on a singleton shared game state, why not just centralise all game state and encode/decode/save the singleton object? Is there a benefit to having each game object know how to encode/decode its own game state data?</p>
<p>David</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-5/#comment-2927</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Thu, 18 Mar 2010 08:00:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-2927</guid>
		<description>Let me know how you get on :o)

Mike</description>
		<content:encoded><![CDATA[<p>Let me know how you get on :o)</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: glen</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-5/#comment-2926</link>
		<dc:creator>glen</dc:creator>
		<pubDate>Thu, 18 Mar 2010 07:58:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-2926</guid>
		<description>Hi Mike
Thanks for the response i have decided that if somethings worth doing its worth doing right. So i have bought the book and im going to start all over again with a better understanding of how to do everything. Only read to chapter 3 so far but im already glad i bought it.
Cheers</description>
		<content:encoded><![CDATA[<p>Hi Mike<br />
Thanks for the response i have decided that if somethings worth doing its worth doing right. So i have bought the book and im going to start all over again with a better understanding of how to do everything. Only read to chapter 3 so far but im already glad i bought it.<br />
Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-5/#comment-2924</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Wed, 17 Mar 2010 19:08:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-2924</guid>
		<description>Hi glen, where are your ints being stored?  Are they within objects you have created, or just held in your main game.

If they are inside objects then the NSCoder stuff should be implemented in those objects to encode the ints.  If they are just in the core game code then you could use an NSDictionary and write its contents out.  This is how I am saving my settings in SLQ e.g. volume
&lt;pre&gt;
	NSNumber *mv = [NSNumber numberWithFloat:sharedSoundManager.musicVolume];
	NSNumber *fv = [NSNumber numberWithFloat:sharedSoundManager.fxVolume];
	NSNumber *lh = [NSNumber numberWithInt:joypadPosition];
	NSNumber *fd = [NSNumber numberWithInt:fireDirection];
	[settings setObject:mv forKey:@&quot;musicVolume&quot;];
	[settings setObject:fv forKey:@&quot;fxVolume&quot;];
	[settings setObject:lh forKey:@&quot;joypadPosition&quot;];
	[settings setObject:fd forKey:@&quot;fireDirection&quot;];
	[settings writeToFile:settingsFilePath atomically:YES];
&lt;/pre&gt;

Loading them back in would use
&lt;pre&gt;
	if([[NSFileManager defaultManager] fileExistsAtPath:settingsFilePath]) {
		SLQLOG(@&quot;INFO - GameController: Found settings file&quot;);
		settings = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsFilePath];
	} else {
		SLQLOG(@&quot;INFO - GameController: No settings file, creating defaults&quot;);
		settings = [[NSMutableDictionary alloc] init];
		[settings setObject:[NSString stringWithFormat:@&quot;%f&quot;, 0.7f] forKey:@&quot;musicVolume&quot;];
		[settings setObject:[NSString stringWithFormat:@&quot;%f&quot;, 0.5f] forKey:@&quot;fxVolume&quot;];
		[settings setObject:[NSNumber numberWithInt:0] forKey:@&quot;joypadPosition&quot;];
		[settings setObject:[NSNumber numberWithInt:0] forKey:@&quot;fireDirection&quot;];
	}
	
	// Get the prefs from the pref file and update the sound manager
	[sharedSoundManager setMusicVolume:[(NSString *)[settings valueForKey:@&quot;musicVolume&quot;] floatValue]];
	[sharedSoundManager setFxVolume:[(NSString *)[settings valueForKey:@&quot;fxVolume&quot;] floatValue]];
	self.joypadPosition = [[settings valueForKey:@&quot;joypadPosition&quot;] intValue];
	self.fireDirection = [[settings valueForKey:@&quot;fireDirection&quot;] intValue];
&lt;/pre&gt;

Hope that helps.

Mike</description>
		<content:encoded><![CDATA[<p>Hi glen, where are your ints being stored?  Are they within objects you have created, or just held in your main game.</p>
<p>If they are inside objects then the NSCoder stuff should be implemented in those objects to encode the ints.  If they are just in the core game code then you could use an NSDictionary and write its contents out.  This is how I am saving my settings in SLQ e.g. volume</p>
<pre>
	NSNumber *mv = [NSNumber numberWithFloat:sharedSoundManager.musicVolume];
	NSNumber *fv = [NSNumber numberWithFloat:sharedSoundManager.fxVolume];
	NSNumber *lh = [NSNumber numberWithInt:joypadPosition];
	NSNumber *fd = [NSNumber numberWithInt:fireDirection];
	[settings setObject:mv forKey:@"musicVolume"];
	[settings setObject:fv forKey:@"fxVolume"];
	[settings setObject:lh forKey:@"joypadPosition"];
	[settings setObject:fd forKey:@"fireDirection"];
	[settings writeToFile:settingsFilePath atomically:YES];
</pre>
<p>Loading them back in would use</p>
<pre>
	if([[NSFileManager defaultManager] fileExistsAtPath:settingsFilePath]) {
		SLQLOG(@"INFO - GameController: Found settings file");
		settings = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsFilePath];
	} else {
		SLQLOG(@"INFO - GameController: No settings file, creating defaults");
		settings = [[NSMutableDictionary alloc] init];
		[settings setObject:[NSString stringWithFormat:@"%f", 0.7f] forKey:@"musicVolume"];
		[settings setObject:[NSString stringWithFormat:@"%f", 0.5f] forKey:@"fxVolume"];
		[settings setObject:[NSNumber numberWithInt:0] forKey:@"joypadPosition"];
		[settings setObject:[NSNumber numberWithInt:0] forKey:@"fireDirection"];
	}

	// Get the prefs from the pref file and update the sound manager
	[sharedSoundManager setMusicVolume:[(NSString *)[settings valueForKey:@"musicVolume"] floatValue]];
	[sharedSoundManager setFxVolume:[(NSString *)[settings valueForKey:@"fxVolume"] floatValue]];
	self.joypadPosition = [[settings valueForKey:@"joypadPosition"] intValue];
	self.fireDirection = [[settings valueForKey:@"fireDirection"] intValue];
</pre>
<p>Hope that helps.</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: glen</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-5/#comment-2923</link>
		<dc:creator>glen</dc:creator>
		<pubDate>Wed, 17 Mar 2010 19:03:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-2923</guid>
		<description>Hi All
I&#039;ve been working with tutorial9 to do my little project and its going good. But ive just started to try and implement some saving when the app quits using tutorial 12. I cant seem to get it working and i wondered if anyone could tell me anything to help or even post an example. All i want to be able to do is save a handfull of ints when the program quits???
Thanks in advance</description>
		<content:encoded><![CDATA[<p>Hi All<br />
I&#8217;ve been working with tutorial9 to do my little project and its going good. But ive just started to try and implement some saving when the app quits using tutorial 12. I cant seem to get it working and i wondered if anyone could tell me anything to help or even post an example. All i want to be able to do is save a handfull of ints when the program quits???<br />
Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-4/#comment-2887</link>
		<dc:creator>Ron</dc:creator>
		<pubDate>Thu, 11 Mar 2010 15:23:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-2887</guid>
		<description>Hi Mike,
     Excellent tutorials!  I&#039;m finding them extremely helpful and informative.  Keep up the great work!

Cheers!</description>
		<content:encoded><![CDATA[<p>Hi Mike,<br />
     Excellent tutorials!  I&#8217;m finding them extremely helpful and informative.  Keep up the great work!</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jjack</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-4/#comment-2834</link>
		<dc:creator>jjack</dc:creator>
		<pubDate>Sat, 06 Mar 2010 14:36:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-2834</guid>
		<description>is it possible to use NSUserDefaults to save the state or is that to memory constraining

Thanks</description>
		<content:encoded><![CDATA[<p>is it possible to use NSUserDefaults to save the state or is that to memory constraining</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://www.71squared.com/2009/12/iphone-game-programming-tutorial-12-saving-state/comment-page-4/#comment-2827</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Fri, 05 Mar 2010 17:49:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.com/?p=1073#comment-2827</guid>
		<description>The largest texture that can be handled in OpenGL ES 1.1 on the iPhone is 1024x1024 pixels.  On the iPhone 3GS using OpenGL ES 2.0 it is 2048x2048.

Unless you really need the features of OpenGL ES 2.0 I would stick with 1.1 which also gives you currently the largest user base, so 1024x1024 is the max.

Hope that helps.

Mike</description>
		<content:encoded><![CDATA[<p>The largest texture that can be handled in OpenGL ES 1.1 on the iPhone is 1024&#215;1024 pixels.  On the iPhone 3GS using OpenGL ES 2.0 it is 2048&#215;2048.</p>
<p>Unless you really need the features of OpenGL ES 2.0 I would stick with 1.1 which also gives you currently the largest user base, so 1024&#215;1024 is the max.</p>
<p>Hope that helps.</p>
<p>Mike</p>
]]></content:encoded>
	</item>
</channel>
</rss>
