<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<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">
	<channel>
		<title>cocos2d for iPhone &#187; Topic: Creating four AtlasSpriteManagers kills the app</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/2213</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 02:00:25 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/topic/2213" rel="self" type="application/rss+xml" />

		<item>
			<title>badawe on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13975</link>
			<pubDate>Thu, 01 Oct 2009 13:40:29 +0000</pubDate>
			<dc:creator>badawe</dc:creator>
			<guid isPermaLink="false">13975@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/2205'>knaecks</a> cool you can solve your problem!</p>
<p>But i realy want to know how is the best way to see real at instruments how to see the Texture Memory!
</p></description>
		</item>
		<item>
			<title>knaecks on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13973</link>
			<pubDate>Thu, 01 Oct 2009 12:29:47 +0000</pubDate>
			<dc:creator>knaecks</dc:creator>
			<guid isPermaLink="false">13973@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>First, thanks again for your hint with the texture memory.</p>
<p>Indeed, my textures were 1024px x 1024px, but only 1024x80px of them were used.<br />
I was running six animations (not four), so if every animation took 4MB, they all took in total exactly 24MB. And no wonder -&#62; Crash :)</p>
<p>I cropped the textures and now everything is working fine.</p>
<p>I tried to use instruments like described in the tutorial, but I also couldn't find the<br />
GART Resident Object Size. Seems the new update after August changed everything, again.</p>
<p>Thank you very much<br />
Greetz knaecks
</p></description>
		</item>
		<item>
			<title>badawe on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13928</link>
			<pubDate>Wed, 30 Sep 2009 19:27:34 +0000</pubDate>
			<dc:creator>badawe</dc:creator>
			<guid isPermaLink="false">13928@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/1338'>chrisco</a> yeah chrisco i try this to, but seens not work, i really dont have any object with this name: “GART Resident Object Size”, so i don't know what i have to check!
</p></description>
		</item>
		<item>
			<title>chrisco on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13922</link>
			<pubDate>Wed, 30 Sep 2009 18:23:29 +0000</pubDate>
			<dc:creator>chrisco</dc:creator>
			<guid isPermaLink="false">13922@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>There were a couple of comments at the bottom of the article about this issue. Not sure if it covers Snow Leopard or not, but for SDK 3.0+, you have to do the steps in a different order. According to the last comment on that page:</p>
<p>"This still works with the 3.0 SDK, however you must select the app to start befor setting the instruments. When I loaded instruments it didnt’ even have an OpenGL ES option, just an “OpenGL Driver” one which had completely different options. Once I selected my iPhone and the app to start then the “OpenGL ES” option appeared, and I could select the options described exactly as written.</p>
<p>The step order should now be: 1, 4, 2, 3, 5, and it works perfectly as of Aug 2009."</p>
<p>Again, not sure if that will help you or not, but worth a shot.
</p></description>
		</item>
		<item>
			<title>badawe on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13921</link>
			<pubDate>Wed, 30 Sep 2009 18:12:16 +0000</pubDate>
			<dc:creator>badawe</dc:creator>
			<guid isPermaLink="false">13921@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/179'>malphigian</a> i usin SnowLeopard with Xcode3.2, and in the link you give us, is for older version!</p>
<p>=/</p>
<p>i don't have “GART Resident Object Size” to see the target size =/</p>
<p>Someone know if have another variable?
</p></description>
		</item>
		<item>
			<title>malphigian on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13909</link>
			<pubDate>Wed, 30 Sep 2009 16:26:40 +0000</pubDate>
			<dc:creator>malphigian</dc:creator>
			<guid isPermaLink="false">13909@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Article on checking texture memory: <a href="http://blog.zincroe.com/2009/04/how-to-check-iphone-texture-memory-usage-with-instruments/" rel="nofollow">http://blog.zincroe.com/2009/04/how-to-check-iphone-texture-memory-usage-with-instruments/</a><br />
(Haven't tried this myself yet, but looks good)</p>
<p>knaecks: Your PNGs are NOT 40kb when they are uncompressed.  Their compressed file size has little do with their memory usage.  A 1024 by 1024 PNG uses 4 megabytes (assuming you are using 32 bit PNGs 1024 x 1024 x 32 in bits) regardless of the size of the compressed file.
</p></description>
		</item>
		<item>
			<title>knaecks on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13904</link>
			<pubDate>Wed, 30 Sep 2009 15:52:20 +0000</pubDate>
			<dc:creator>knaecks</dc:creator>
			<guid isPermaLink="false">13904@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thank you badawe for your "stupid question". I got the same. :)<br />
How can I check this?</p>
<p>And how can the Texture Memory Usage be over 24 MB? My pngs are all about 40kb.</p>
<p>And I'm still having the question if this is the correct way to add a new Manager for each Animation.</p>
<p>Thank you
</p></description>
		</item>
		<item>
			<title>badawe on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13902</link>
			<pubDate>Wed, 30 Sep 2009 15:39:49 +0000</pubDate>
			<dc:creator>badawe</dc:creator>
			<guid isPermaLink="false">13902@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/131'>Steve</a> sorry about this stupid question, but how i check my texture memory usage? Have some instrument? or printing something in the screen?
</p></description>
		</item>
		<item>
			<title>Steve Oldmeadow on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13897</link>
			<pubDate>Wed, 30 Sep 2009 15:23:11 +0000</pubDate>
			<dc:creator>Steve Oldmeadow</dc:creator>
			<guid isPermaLink="false">13897@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Check your texture memory usage.  My guess is the fourth animation pushes you over 24Mb.
</p></description>
		</item>
		<item>
			<title>knaecks on "Creating four AtlasSpriteManagers kills the app"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2213#post-13888</link>
			<pubDate>Wed, 30 Sep 2009 14:46:13 +0000</pubDate>
			<dc:creator>knaecks</dc:creator>
			<guid isPermaLink="false">13888@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi everyone,</p>
<p>I'm searching for some hours now, reading every thread here, but still finding no solution for my Problem. So I hope you guys can help me killing this bug. :)</p>
<p>I've a character with many different Animations. He walks, he jumps, he idles and so on...<br />
For every animation I got a png file with the Sprite-Atlas and a .plist file with the coordinates of the single images.</p>
<p>Now I wrote a function which generates, for each Sprite-Atlas, a new Manager, a new Sprite and a new SpriteAnimation and stores them in a dictionary, which is the return value of this function.</p>
<p>The function is located in my Singelton Manager Class, so I can call it from all my other Classes to generate a new Animation. So the character, the enemies, the world are calling this function.</p>
<p>The returned dictionary will be added to a Dictionary-Property in these objects and the manager will be added as a child to the layer.</p>
<p>Now everytime I need a specific animation I make the Sprite visible and start its Animation.</p>
<p>Three Animations worked fine in one class but the fourth one kills the app. It starts to stutter very hardly. CPU Usage seems to be 100% but only on the devices, NOT in the simulator.</p>
<p>What can be the problem?<br />
Do I realy need a new Manager for every .png Sprite-Atlas?</p>
<p>Thank you very much,</p>
<p>here is an example call:<br />
<pre><code>[self.animationDict addEntriesFromDictionary:[[Manager defaultManager] generateNewAnimaton:@&#34;walk&#34; capacity:32 image:@&#34;walk.png&#34; delay:0.04f width:71 height:64 seq:@&#34;walk.plist&#34;]];

[self addChild:[animationDict valueForKey:@&#34;walkManager&#34;] z:1];</code></pre>
<p>here's the function:</p>
<pre><code>- (NSMutableDictionary*) generateNewAnimaton: (NSString*)name capacity:(int)capacity image:(NSString*)image delay:(float)delay width:(int)width height:(int)height seq:(NSString*)sequence
{
	animationDict = [NSMutableDictionary dictionary];

	AtlasSpriteManager* manager = [AtlasSpriteManager spriteManagerWithFile:image capacity:capacity];
	AtlasAnimation* animation   = [AtlasAnimation animationWithName:name delay:delay];

	NSDictionary* d = [NSDictionary dictionaryWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:sequence]];

	NSArray* kList = [[d allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; 

	for( NSString* key in kList )
	{
		NSDictionary* myDict = [d objectForKey:key];

		NSInteger x = [[myDict valueForKey:@&#34;x&#34;] integerValue];
		NSInteger y = [[myDict valueForKey:@&#34;y&#34;] integerValue];
		NSInteger w = [[myDict valueForKey:@&#34;w&#34;] integerValue];
		NSInteger h = [[myDict valueForKey:@&#34;h&#34;] integerValue];

		[animation addFrameWithRect: CGRectMake( x, y, w, h ) ];
	}

	AtlasSprite* sprite;

	sprite = [AtlasSprite spriteWithRect:CGRectMake( 1, 1, width, height ) spriteManager: manager];

	sprite.visible = false;
	sprite.transformAnchor = CGPointMake( 0, 0 );

	[manager addChild:sprite];

	[animationDict setValue:manager   forKey:[name stringByAppendingString:@&#34;Manager&#34;]];
	[animationDict setValue:animation forKey:[name stringByAppendingString:@&#34;Animation&#34;]];
	[animationDict setValue:sprite    forKey:[name stringByAppendingString:@&#34;Sprite&#34;]];

	return animationDict;
}</code></pre></description>
		</item>

	</channel>
</rss>

