<?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; Tag: performance - Recent Topics</title>
		<link>http://www.cocos2d-iphone.org/forum/tags/performance</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 04:21:43 +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/tags/performance/topics" rel="self" type="application/rss+xml" />

		<item>
			<title>Mister_Cheese on "Animated pod file, objects disappearing."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/29023#post-143098</link>
			<pubDate>Tue, 07 Feb 2012 18:23:39 +0000</pubDate>
			<dc:creator>Mister_Cheese</dc:creator>
			<guid isPermaLink="false">143098@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have an pod file of an animated character created in max and have been having an issue where parts of his body will disappear, or the animation will go funky.  ie His hat will at his neck instead of on his head.</p>
<p>I use the following code to load the model and start the animation.<br />
<pre><code>CC3MeshNode* mn;
CC3ResourceNode* rezNode;
rezNode = [CC3PODResourceNode nodeFromResourceFile:@&#34;Learning_Companion_Anim_Ambient01.POD&#34;];
mn = (CC3MeshNode*)[rezNode getNodeNamed: @&#34;Dummy01&#34;];
mn.isOpaque = NO;
[self addChild:mn];
CCActionInterval* LCLoop = [CC3Animate actionWithDuration: kAnimationTime limitFrom: 0.0 to: 1.0];
[mn runAction: [CCRepeatForever actionWithAction:LCLoop]];</code></pre>
<p>After some messing around, I have discovered that using OpenEars, an open source library for voice recognition <a href="http://www.politepix.com/openears" rel="nofollow">http://www.politepix.com/openears</a>   It seems to be the cause for parts of the body disappearing.  If I never start openears from listening for audio input the model animates fine.  If the animation is never started with runAction, then the model appears correctly and none of his body parts are missing.</p>
<p>I was hoping someone might have some insight as to why this library would be messing up the animations running in cocos3d.  I also realize my chances at getting help on this are slim to none as the problem is stemming from conflicting libaries, so I would really appreciate any insight.</p>
<p>Thanks,<br />
Andrew
</p></description>
		</item>
		<item>
			<title>rolando on "[ShinyCocos] First public release: 0.1.0 (Birthday Pinata)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1163#post-7005</link>
			<pubDate>Thu, 06 Aug 2009 18:57:01 +0000</pubDate>
			<dc:creator>rolando</dc:creator>
			<guid isPermaLink="false">7005@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi all,<br />
I'm really happy to announce the first public release of ShinyCocos: 0.1.0 (Birthday Pinata)</p>
<p>What the heck is ShinyCocos? In a few words: ruby bindings for cocos2d-iphone. We have already sent to apple our first "test" game using ShinyCocos, and we are expecting an answer from apple anytime now.</p>
<p>You can grab your copy of ShinyCocos here:</p>
<p><a href="http://github.com/funkaster/shinycocos/zipball/0.1.0" rel="nofollow">http://github.com/funkaster/shinycocos/zipball/0.1.0</a></p>
<p>The release includes a sample project (TestProject) and the official documentation is hosted on github:</p>
<p><a href="http://funkaster.github.com/shinycocos/" rel="nofollow">http://funkaster.github.com/shinycocos/</a></p>
<p>Anyway, that's all, I'm tired and I still have to finish our real first game :-D<br />
Enjoy!</p>
<p>rolando./
</p></description>
		</item>
		<item>
			<title>flagman on "Cocos3d:General Performance Improvement Tips"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28585#post-140782</link>
			<pubDate>Mon, 23 Jan 2012 06:16:02 +0000</pubDate>
			<dc:creator>flagman</dc:creator>
			<guid isPermaLink="false">140782@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I implemented simple 3d shooter using cocos3d and very impressed by this engine. Many thanks to its creators.<br />
I used iphone 4 as target development device, and my code works fine on this device.<br />
But when i tried to run this code on iphone 3, i faced with bad performance. </p>
<p>Is there any general tips to improve performance?<br />
For example in cocos2d -  I have to use sprites sheet to get huge performance boost.</p>
<p>Thank you.
</p></description>
		</item>
		<item>
			<title>itlgames on "Performance tips"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/9910#post-56970</link>
			<pubDate>Sun, 26 Sep 2010 17:00:10 +0000</pubDate>
			<dc:creator>itlgames</dc:creator>
			<guid isPermaLink="false">56970@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, I have been optimizing the performance on my game on the last weeks and made a good discovers, maybe obvious, but I didn't realise until now.</p>
<p>First, we will note all the performance of our game is based in two things, rendering and logic. Regarding rendering, this implies using sprite sheets and things like that, and also will depend how many different elements you have on your layers.</p>
<p>I realised that if the bottleneck of your game is rendering, tests tend to run faster on the device than in the simulator. But if the bottleneck is the logic, it's the other way round, simulator runs faster than device. Makes sense, simulator uses computer CPU for logic, but simulated GPU for rendering, and device uses real GPU and CPU is usually slower than computer.</p>
<p>So I won't talk about the rendering optimizations as this has been discussed on the forums many times. I will talk about logic improvements.</p>
<p>Probably the main logic of your game will be done in a simple loop, or at least I think it's the best way to do. Using Instruments and CPU Sampler, you can investigate where your code fails. Be sure you follow tips on this <a href="http://allseeing-i.com/Performance-tips-for-Cocos2d-for-iPhone">link</a></p>
<p>Ok, so after lot of hours investigating, I discovered few tips:</p>
<p>1) when declaring properties on your classes, use nonatomic declaration if you can:</p>
<p><code>@property(nonatomic,assign) float altitude;</code></p>
<p>2) If you use heavily arrays, use CCArray instead of NSMutableArray or NSArray. To loop also use the fast enumerator:</p>
<pre><code>for (CellObject * object in objects) {
...
}</code></pre>
<p>But, if you need to access the index of the object on the array, then is faster using a traditional for:</p>
<pre><code>for (int i = 0; i &#60; self.numObjects; i++) {
...
}</code></pre>
<p>cos the cost to <strong>indexOfObject</strong> is high.</p>
<p>3) pre-calculate any values you can, i.e. if you have float divisions of constant variables, never do them on the fly every schedule tick, save the calculations in intermediary variables and then use them.</p>
<p>4) I believe float types run faster than double, as float are 32 bits and double 64 bits, but I am not 100% sure on this.</p>
<p>5) If you loop through your objects, to i.e. find a collision, once you find the collision, use <strong>break</strong> to exit the for loop, unless you need to use all hit objects (usually the first hit object should be ok)</p>
<p>Doing all those things you can manage to scrap a few fps, very important when performance is critical.</p>
<p>Would be good to see other people impressions and experiences as well, as I am sure I am missing more things, or I could be wrong in some others.
</p></description>
		</item>
		<item>
			<title>neigaard on "Optimizing CCParticleSystemQuad"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28232#post-138897</link>
			<pubDate>Tue, 10 Jan 2012 13:55:46 +0000</pubDate>
			<dc:creator>neigaard</dc:creator>
			<guid isPermaLink="false">138897@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>I have been looking for a way to optimized my use of particles. I have many CCParticleSystemQuad emitters that display the same at the same time, and I found this thread:</p>
<p><a href="http://www.cocos2d-iphone.org/forum/topic/177" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/177</a></p>
<p>This seems to be exactly what I need, but I can not figure out how to get it to work with CCParticleSystemQuad. So this thread is an attempt to get some new attention to that older thread and get some help getting my many emitters to perform well.</p>
<p>Thank you<br />
Søren
</p></description>
		</item>
		<item>
			<title>adpro on "Optimize ParticleSystems"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/177#post-910</link>
			<pubDate>Thu, 18 Jun 2009 19:31:40 +0000</pubDate>
			<dc:creator>adpro</dc:creator>
			<guid isPermaLink="false">910@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,</p>
<p>As some of you know, I was asking questions about some other stuff earlier and it led me to the suggestion of pre-allocating particles for my ParticleExplosion I am using for my game.</p>
<p>Basically, I am using a bunch of particle explosions when sprites interact.  Think of space invaders, but with different types of bullets that interact differently with different enemies.  A lot of the time, there will be explosions when two sprites interact.  Many explosions can be going on at the same time - in fact, there are usually at least 2 explosions going on at the exact same time.</p>
<p>I figured I would start a thread to help me, and others in search of the same answers, find answers to optimizing particle systems for their games.</p>
<p>After a bunch of explosions happen in my game (there has to be a lot), it slows down to about 30-40fps.  It doesn't start slowing down until after about 150-200+ explosions.</p>
<p>It was suggested to pre-allocate the particles.  I have gone into particle.m and other files, but haven't been able to figure out how to do this exactly.  I'm also new to chipmunk, cocos2d, cocoa and objective-c, so maybe I am missing something simple.  I searched google to see if there was anything, but I couldn't find anything.</p>
<p>I'm thinking these answers would help a lot of people, so any information would be greatly appreciated.  I'll post what I find as well in here.</p>
<p>Thanks all!
</p></description>
		</item>
		<item>
			<title>manucorporat on "CCArray: Performance and usability"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/6793#post-39836</link>
			<pubDate>Wed, 02 Jun 2010 16:40:04 +0000</pubDate>
			<dc:creator>manucorporat</dc:creator>
			<guid isPermaLink="false">39836@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have developed a great class, and I have implemented it in cocos2d.</p>
<p>"CCArray" is like "NSArray" but it's much faster. (based in ccArray)</p>
<p>Some example using CCArray versus NSArray:</p>
<p>Init:<br />
<pre><code>CCArray *array = [CCArray arrayWithCapacity:30];

for (int i = 0; i&#60;30; i++){
[array addObject:[NSNumber numberWithInt:435]]; //Same that NSArray
}</code></pre>
<p><strong>1. - Very very faster. (This way should be used in the cocos2d kernel)</strong></p>
<pre><code>ccArray *arrayData = [array data];
for(int i = 0; i&#60; arrayData-&#62;num; i++){
id object = arrayData-&#62;arr[i];
//Here your code
}</code></pre>
<p><strong>2. - The usability code (like NSArray):</strong><br />
<pre><code>for(id object in array){ //CCArray is conforms to NSFastEnumerator protocol
//Here your code
}</code></pre>
<p><strong>And the better is that you can replace all NSArray in cocos2d and it works sucessfully.<br />
</strong></p>
<p>Edit: I am going to publish the code very soon.
</p></description>
		</item>
		<item>
			<title>Lonzz on "CCRenderTexture has big performance hit"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/27867#post-136846</link>
			<pubDate>Sun, 25 Dec 2011 15:06:53 +0000</pubDate>
			<dc:creator>Lonzz</dc:creator>
			<guid isPermaLink="false">136846@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi guys,</p>
<p>I am currently working on a simple game that is using single color backgrounds. So far I have been using CCRenderTexture to draw the background once and then use it as a CCSprite. I have several backgrounds overlaying each other with the bottom one being fullscreen. But even if I am only using my smallest background which is half the screen, my framerate drops significantly.<br />
From your experience what would be your way of choice to create one color backgrounds/sprites? </p>
<p>Many thanks,</p>
<p>Christoph
</p></description>
		</item>
		<item>
			<title>woaicocos2d on "uialertview"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/21008#post-116768</link>
			<pubDate>Mon, 19 Sep 2011 08:56:40 +0000</pubDate>
			<dc:creator>woaicocos2d</dc:creator>
			<guid isPermaLink="false">116768@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hi guys,<br />
     in my game,i need a view like UIAlertview ,but i need put three uitextfiled on the alertview. so,first i add a view to the uialertview which  can cover the whole alertview,then i add some uitextfiled on the view.but i can not  get the focus of  the uitextfiled, there is no reply for my click.<br />
the code is below:</p>
<p>- (void)loadAlertView:(int)account<br />
{<br />
   if (self) {<br />
       post = [[UIView alloc]initWithFrame:CGRectMake(0,-200, 300, 275)];<br />
       post.backgroundColor = [UIColor lightGrayColor];<br />
       [post.layer setCornerRadius: 10.0f];<br />
       [self addSubview:post];<br />
       [self setBackgroundColor: [UIColor clearColor]];<br />
       UILabel *accountLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 140, 30)];<br />
       accountLabel.text = @"帐号：";<br />
       accountLabel.backgroundColor = [UIColor clearColor];<br />
       accountLabel.textColor = [UIColor whiteColor];<br />
       [post addSubview:accountLabel];<br />
       [accountLabel release];</p>
<p>       accountTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 240, 30)];<br />
       accountTextField.backgroundColor = [UIColor whiteColor];<br />
       accountTextField.text = [NSString stringWithFormat:@"%d",account];;<br />
       [post addSubview:accountTextField];<br />
       accountTextField.delegate =self;</p>
<p>       UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 90, 140, 20)];<br />
       titleLabel.text = @"标题：";<br />
       titleLabel.backgroundColor = [UIColor clearColor];<br />
       titleLabel.textColor = [UIColor whiteColor];<br />
       [post addSubview:titleLabel];<br />
       [titleLabel release];</p>
<p>       titleTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 110, 240, 30)];<br />
       titleTextField.backgroundColor = [UIColor whiteColor];<br />
       [post addSubview:titleTextField];<br />
       [titleTextField becomeFirstResponder];<br />
       //注意先add 在添加</p>
<p>       UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 140, 140, 20)];<br />
       contentLabel.text = @"内容：";<br />
       contentLabel.backgroundColor = [UIColor clearColor];<br />
       contentLabel.textColor = [UIColor whiteColor];<br />
       [post addSubview:contentLabel];<br />
       [contentLabel release];</p>
<p>       contentTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 160, 240, 30)];<br />
       [post addSubview:contentTextField];<br />
       contentTextField.backgroundColor = [UIColor whiteColor];</p>
<p>       UIButton *send = [UIButton buttonWithType:UIButtonTypeRoundedRect];<br />
       [send setFrame:CGRectMake(25,210,80,30)];</p>
<p>       [post addSubview:send];<br />
       send.backgroundColor = [UIColor clearColor];<br />
       [send setTitle:@"发送" forState:UIControlStateNormal];<br />
       [send addTarget:self action:@selector(sendButtonClick) forControlEvents:UIControlEventTouchUpInside];</p>
<p>       UIButton *cancel = [UIButton buttonWithType:UIButtonTypeRoundedRect];<br />
       [cancel setFrame:CGRectMake(150,210,80,30)];<br />
       [post addSubview:cancel];<br />
       cancel.backgroundColor = [UIColor clearColor];<br />
       [cancel setTitle:@"取消" forState:UIControlStateNormal];<br />
       [cancel addTarget:self action:@selector(cancelButtonClick) forControlEvents:UIControlEventTouchUpInside];<br />
       [self show];<br />
   }<br />
}    </p>
<p>can anybody help me? Thanks a lot
</p></description>
		</item>
		<item>
			<title>mayaz7_ayaz on "CCDraw Cubic Curve Line."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25528#post-132847</link>
			<pubDate>Mon, 12 Dec 2011 09:26:17 +0000</pubDate>
			<dc:creator>mayaz7_ayaz</dc:creator>
			<guid isPermaLink="false">132847@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I am creating a game in cocos2d. in my game i am draw Multiple CubicBezier Lines, like a lace. on touches move i want to curve this lines. This is complete dynamically.
</p></description>
		</item>
		<item>
			<title>galenzo17 on "Performance on Ipad, load sprite´s (StoryBook)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25377#post-132051</link>
			<pubDate>Wed, 07 Dec 2011 12:45:08 +0000</pubDate>
			<dc:creator>galenzo17</dc:creator>
			<guid isPermaLink="false">132051@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi!</p>
<p>My code:</p>
<p>/////////////////////////////////  nandu.h    /////////////////////////////////////////</p>
<p>@interface nandu : CCLayer<br />
{<br />
	CCSprite *fondo;<br />
	//CCParticleRain *lluvialenguad;<br />
}</p>
<p>+(CCScene *) scene;</p>
<p>@end</p>
<p>///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////</p>
<p>/////////////////////////////////  nandu.m    /////////////////////////////////////////</p>
<p>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> "nandu.h"</p>
<p>@implementation nandu</p>
<p>+(CCScene *) scene<br />
{<br />
	// 'scene' is an autorelease object.<br />
	CCScene *scene = [CCScene node];</p>
<p>	// 'layer' is an autorelease object.<br />
	nandu *layer = [nandu node];</p>
<p>	// add layer as a child to scene<br />
	[scene addChild: layer];</p>
<p>	// return the scene<br />
	return scene;<br />
}</p>
<p>-(void)starButtonTapped{</p>
<p>	[[bookmanager sharedbookmanager] runSceneWithID:kcuruscene];</p>
<p>}</p>
<p>// on "init" you need to initialize your instance<br />
-(id) init<br />
{<br />
	// always call "super" init<br />
	// Apple recommends to re-assign "self" with the "super" return value<br />
	if( (self=[super init])) {</p>
<p>                isTouchEnabled_=YES;</p>
<p>		[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"curunandu.plist"];</p>
<p>		fondo =[CCSprite spriteWithFile:@"fondonandu.png"];<br />
		fondo.position=ccp(384,514);</p>
<p>		[self addChild:fondo z:-2];</p>
<p>		CCSprite *nandiu=[CCSprite spriteWithSpriteFrameName:@"nandusinfondo.png"];<br />
		//lenguado.anchorPoint=ccp(0,0);<br />
		nandiu.position= ccp(391, 637);<br />
		nandiu.tag=100;<br />
		[self addChild:nandiu];</p>
<p>		CCMenuItem *adelante = [CCMenuItemImage<br />
								itemFromNormalImage:@"1.png" selectedImage:@"1.png"<br />
								target:self selector:@selector(starButtonTapped)];<br />
		adelante.position = ccp(640, 60);</p>
<p>		CCMenuItem *atras = [CCMenuItemImage<br />
							 itemFromNormalImage:@"3.png" selectedImage:@"3.png"<br />
							 target:self selector:@selector(starButtonTapped)];<br />
		atras.position = ccp(130, 60);</p>
<p>		CCMenuItem *indice = [CCMenuItemImage<br />
							  itemFromNormalImage:@"2.png" selectedImage:@"2.png"<br />
							  target:self selector:@selector(starButtonTapped)];<br />
		indice.position = ccp(388, 100);</p>
<p>		CCMenuItem *ficha = [CCMenuItemImage<br />
							 itemFromNormalImage:@"botonfichatransparente.png" selectedImage:@"botonfichatransparente.png"<br />
							 target:self selector:@selector(starButtonTapped)];<br />
		ficha.position = ccp(189, 254);</p>
<p>		CCMenuItem *texto = [CCMenuItemImage<br />
							 itemFromNormalImage:@"botontransparentetexto.png" selectedImage:@"botontransparentetexto.png"<br />
							 target:self selector:@selector(starButtonTapped)];<br />
		texto.position = ccp(583, 305);</p>
<p>		CCMenu *starMenu = [CCMenu menuWithItems:adelante,atras,indice,ficha,texto, nil];<br />
		starMenu.position = CGPointZero;<br />
		[self addChild:starMenu];<br />
	}<br />
	return self;<br />
}</p>
<p>////Is this OK? mmmmm, I think maybe not, but work///////</p>
<p>-(void) ccTouchesBegan :(NSSet *) touches withEvent :(UIEvent *)event<br />
{<br />
	UITouch *touch =[touches anyObject];<br />
	CGPoint location= [touch locationInView:[touch view]];<br />
	location=[[CCDirector sharedDirector]convertToGL:location];</p>
<p>	CCSprite *nandusinfondo=(CCSprite *)[self getChildByTag:100];</p>
<p>	id effect = [CCWaves actionWithWaves:10 amplitude:10 horizontal:YES vertical:YES grid:ccg(10, 10) duration:3];<br />
	[nandusinfondo runAction:effect];</p>
<p>}</p>
<p>- (void) dealloc<br />
{<br />
	[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];</p>
<p>	// don't forget to call "super dealloc"<br />
	[super dealloc];<br />
}</p>
<p>@end</p>
<p>///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////<br />
///////////////////////////////********************/////////////////////////<br />
My  code works at 15 fps</p>
<p>And I have a BookManager and constant</p>
<p>My questions:</p>
<p>-How i can change my code for better performance?  Any Ideas? :)<br />
-I have 65 page to do; Is this the best way?<br />
-15 fps on device is ok? or crash all the time?<br />
-is this  the best way for sprites load?<br />
-All my art work is in .png; I have to change to .pvr?</p>
<p>i'm new on cocos2d and I almost finished my work and i need from the experience voice</p>
<p>and a study a lot before ask</p>
<p>sorry for my english i´m from Argentina like Riq!</p>
<p>best regards
</p></description>
		</item>
		<item>
			<title>cokoco on "Speed performance issue with Cocos2d VS UIKit"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/24831#post-130931</link>
			<pubDate>Sat, 03 Dec 2011 17:28:44 +0000</pubDate>
			<dc:creator>cokoco</dc:creator>
			<guid isPermaLink="false">130931@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>My current project is a synth for Iphone. And I have been having some lag problems between the point one touches the screen until the sound actually comes out.<br />
So I have done some tests :)</p>
<p>I implemented the synth object into Uikit, using UIButtons and IBOutlets to trigger my synth methods.<br />
The testes are done recording my finger hitting the screen and measuring the time in milliseconds until the sound plays.</p>
<p>Using UIKit average delay is approximately:  86,30 ms which i think is acceptable.<br />
Implementing the same code into  a cocos2d template, and triggering the sound using the cctouchesbegan method results in: 110.75 ms delay. (varying between 140ms ang 100)</p>
<p>Using the synth as a global singleton object seems to give about the same delay as importing the synth code directly in the main layer in cocos2d.<br />
 Though there seem to be a 10 ms difference in delay between the two in UIKit, where using the synth as singleton have more delay than having the code loaded into the mainViewController (which only gave 86 ms delay).</p>
<p>What are your thoughts on this? Is UIKit faster than Cocos2d?<br />
If you have any tips on how to investigate this further, I would be very appreciative as I am very new to software development.
</p></description>
		</item>
		<item>
			<title>aramk on "CCSpriteBatchNode with large transparent backgrounds"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/23964#post-129077</link>
			<pubDate>Sun, 27 Nov 2011 16:22:54 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">129077@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've written a bunch of classes for creating a parallax effect background which contains the ground, hills and clouds. Each object is duplicated once and this allows me to create an infinite loop with the ground etc. Problem is, using CCSpriteBatchNode and 12 x PNG 32bit textures with approx. size 600 x 200px slows down my FPS to around 30. I have read that using CCSpriteBatchNode shows big improvements in performance, but I can't seem to replicate them.</p>
<p><a href="http://www.learn-cocos2d.com/2011/09/cocos2d-spritebatch-performance-test/" rel="nofollow">http://www.learn-cocos2d.com/2011/09/cocos2d-spritebatch-performance-test/</a></p>
<p>How can I speed things up?
</p></description>
		</item>
		<item>
			<title>KeitZer on "Box2d performance issues all of a sudden"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22630#post-125546</link>
			<pubDate>Fri, 11 Nov 2011 14:12:49 +0000</pubDate>
			<dc:creator>KeitZer</dc:creator>
			<guid isPermaLink="false">125546@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Using cocos2d version 1.0.0-rc3 (I have been for a while) I made a mini-golf game that used box2d for the gravity-less physics (basically using the ball to bounce off the walls, you get the idea).</p>
<p>Up until now, I haven't had any hills in my mini-golf game, so I decided to implement them by using a b2staticBody as a sensor and set gravity when the ball is "colliding" with the body.</p>
<p>Well, without the code below, I'm consistently at 60 FPS, but once I add this code, it jumps from 40-60 and makes the game really choppy/laggy. I only have 2 bodies (sometimes 3) without the ramps. And even with the ramps, I have up to 6 (3 non-ramps, 3 ramps, max), yet I'm seeing performance drops which is bugging the hell outta me.</p>
<p>Anyways, here's the code that when added causes issues (at the bottom of the init method)<br />
<pre><code>CCSprite *ramp1, *ramp2, *ramp3;

            b2BodyDef rampBodyDef1;
            b2Body *rampBody1;
            b2BodyDef rampBodyDef2;
            b2Body *rampBody2;
            b2BodyDef rampBodyDef3;
            b2Body *rampBody3;

            ramp1 = [CCSprite spriteWithSpriteFrameName:frameName];
            ramp2 = [CCSprite spriteWithSpriteFrameName:frameName];
            ramp3 = [CCSprite spriteWithSpriteFrameName:frameName];
            ramp1.position = ccp(240,160);
            ramp2.position = ccp(240,160);
            ramp3.position = ccp(240,160);
            [self addChild:ramp1 z:-1];
            [self addChild:ramp2 z:-1];
            [self addChild:ramp3 z:-1];

            rampBodyDef1.type = b2_staticBody;
            rampBodyDef2.type = b2_staticBody;
            rampBodyDef3.type = b2_staticBody;

            rampBodyDef1.position.Set(ramp1.position.x/PTM_RATIO, ramp1.position.y/PTM_RATIO);
            rampBodyDef2.position.Set(ramp2.position.x/PTM_RATIO, ramp2.position.y/PTM_RATIO);
            rampBodyDef3.position.Set(ramp3.position.x/PTM_RATIO, ramp3.position.y/PTM_RATIO);

            rampBodyDef1.userData = ramp1;
            rampBodyDef2.userData = ramp2;
            rampBodyDef3.userData = ramp3;

            rampBody1 = _world-&#62;CreateBody(&#38;rampBodyDef1);
            rampBody2 = _world-&#62;CreateBody(&#38;rampBodyDef2);
            rampBody3 = _world-&#62;CreateBody(&#38;rampBodyDef3);

            if (hole == 3)
            {
                ramp1.tag = 131;
                rampBody1 = [OutOfBoundVerts getBodyForRamp:rampBody1 rampNumber:1];
            }
            else if (hole == 5)
            {
                ramp1.tag = 151;
                ramp2.tag = 152;
                rampBody1 = [OutOfBoundVerts getBodyForRamp:rampBody1 rampNumber:1];
                rampBody2 = [OutOfBoundVerts getBodyForRamp:rampBody2 rampNumber:2];
            }
            else if (hole == 7)
            {
                ramp1.tag = 171;
                rampBody1 = [OutOfBoundVerts getBodyForRamp:rampBody1 rampNumber:1];
            }
            else if (hole == 8)
            {
                ramp1.tag = 181;
                rampBody1 = [OutOfBoundVerts getBodyForRamp:rampBody1 rampNumber:1];
            }
            else if (hole == 9)
            {
                ramp1.tag = 191;
                ramp2.tag = 192;
                ramp3.tag = 193;
                rampBody1 = [OutOfBoundVerts getBodyForRamp:rampBody1 rampNumber:1];
                rampBody2 = [OutOfBoundVerts getBodyForRamp:rampBody2 rampNumber:2];
                rampBody3 = [OutOfBoundVerts getBodyForRamp:rampBody3 rampNumber:3];
            }</code></pre>
<p>Basically I create the sprites to tag them (multiple ramps going in different directions), set them static and their position and the userdata then create the body. I use the OutOfBoundVerts class (it doesn't really matter where it's at, the method would be the same) to set the new shape/fixture for the ramp's body based on which ramp it is.</p>
<p>Now like I said, only when adding these lines of code does it cause performance hits, which is mind-boggling since I've read people only getting hits like what I've described once having over 200 bodies.</p>
<p>I've already set the optimization to -Os (thinking that would help, but it didn't) and tried getting rid of continuous physics but that causes issues when the ball interacts with the walls at high speed.</p>
<p>Any help would be really appreciated as this is going in the free version of the game and I'd also like to implement it in the full version soon too.</p>
<p>Thanks,<br />
KeitZer
</p></description>
		</item>
		<item>
			<title>wybielacz on "iOS5 + cocos2d 2.0.0 performance issues"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22134#post-122985</link>
			<pubDate>Tue, 25 Oct 2011 20:14:58 +0000</pubDate>
			<dc:creator>wybielacz</dc:creator>
			<guid isPermaLink="false">122985@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,<br />
Recently I sent out the first beta of my upcoming game to the beta testers and I was completely surprised when they told me that the game runs with under 30 fps on an iPhone4 and iPad1 since the fpson my 3GS was all the time solid 60. I spent days optimizing and searching for the issue without any success. The only difference was the iOS 5.0 - beta testers iOS 4.3 - my 3GS. Today I updated my 3GS and the exact same code that ran solid 60 fps on 4.3 runs most of the time under 40 fps on 5.0<br />
I sent out a Hello world template to my testers with just 1 full screen background image and 1 transparent sprite and on the iPhone4 and iPad the FPS drops already to 30!<br />
Did anyone experience such problems? How about cocos2d 1.x? Did anyone notice performance issues with iOS5 ?
</p></description>
		</item>
		<item>
			<title>mobilepot on "[space manager] slow performance"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/21780#post-120967</link>
			<pubDate>Thu, 13 Oct 2011 02:21:08 +0000</pubDate>
			<dc:creator>mobilepot</dc:creator>
			<guid isPermaLink="false">120967@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hello</p>
<p>i created  cpCCSprite and Shape number of 64.</p>
<p>but its very slow fps 6~15</p>
<p>i made cpCCSprite by spriteWithSpriteFrameName with plist file.<br />
shape's size 8 px.</p>
<p>is it wrong? How improve performance with many small shapes??
</p></description>
		</item>
		<item>
			<title>diogorh on "Simulator vs Device"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/20319#post-112994</link>
			<pubDate>Sat, 27 Aug 2011 15:08:01 +0000</pubDate>
			<dc:creator>diogorh</dc:creator>
			<guid isPermaLink="false">112994@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I haven't tried my game on the device yet. So I wanted to know if is there much difference on the performance between both?</p>
<p>I have a side scrolling game that has a varying FPS of 40 to 60. Would it the be the same in the device? </p>
<p>If it matters my machine has a 2.1Ghz dual core  cpu and 4Gb ram.</p>
<p>Thx for any answer :)
</p></description>
		</item>
		<item>
			<title>pimms on "Looking for options for drawing sprites (tiles)"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/20050#post-111867</link>
			<pubDate>Mon, 22 Aug 2011 13:06:34 +0000</pubDate>
			<dc:creator>pimms</dc:creator>
			<guid isPermaLink="false">111867@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Greetings!</p>
<p>I'm using tiles in my game, and I'm not happy about the performance at all. I use 10 different white 32x32 tiles and put a color-overlay on them. I'm only drawing what's inside the screens boundaries at all times.</p>
<p>What I'm actually after is a way of "drawing a sprite once, at several locations". </p>
<p>I realize the Particle Engine must be doing something very fancy in order to draw as fast as it does, and after looking through the draw method of CCParticleSystemQuad, I'm still not smarter on said subject. Does anyone know how to do this with regular sprites as well?</p>
<p>Thanks in advance!
</p></description>
		</item>
		<item>
			<title>Shogan on "Spritesheets &amp; Parallax voidnode - performance / how to question"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/16167#post-91248</link>
			<pubDate>Mon, 02 May 2011 21:16:00 +0000</pubDate>
			<dc:creator>Shogan</dc:creator>
			<guid isPermaLink="false">91248@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi guys,</p>
<p>I am using a CCParallax node, which I add multiple sprites to for a scrolling parallax background. This works quite well. I am using sprites from a sprite sheet on this parallax background and it has about 6 different bits to it.</p>
<pre><code>CCSprite *water = [CCSprite spriteWithSpriteFrameName:@&#34;water.png&#34;];
water.anchorPoint = ccp(0,0);
CCSprite *skyLayer = [CCSprite spriteWithSpriteFrameName:@&#34;sky.png&#34;];
skyLayer.anchorPoint = ccp(0,0);
CCSprite *terrain = [CCSprite spriteWithSpriteFrameName:@&#34;terrain.png&#34;];
terrain.anchorPoint = ccp(0,0);

CCParallaxNode *voidNode =  [CCParallaxNode node];
[voidNode addChild:skyLayer z:-2 parallaxRation:ccp(0.0f,0.0f) positionOffset:ccp(0,0)];
[voidNode addChild:terrain z:4 parallaxRation:ccp(1.0f,1.0f) positionOffset:ccp(0,0)];
[voidNode addChild:water z:-1 parallaxRation:ccp(0.3f,1.0f) positionOffset:ccp(0,0)];

[self addChild:voidNode z:1 tag:kTagNode];</code></pre>
<p>So as you can see by my code above, I am not adding the sprites from the spritesheet as children of my spritesheet (CCSpriteBatchNode). As I understand it, to get the best performance, my sprites that are going on the CCParallaxNode should be children of the CCSpriteBatchNode.</p>
<p>How would I go about doing this? If I am being stupid please shout / indicate where my noobness is stemming from :)</p>
<p>Cheers :)
</p></description>
		</item>
		<item>
			<title>vashpan on "&#039;addChild&#039; performance -&gt; tips"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19708#post-110311</link>
			<pubDate>Fri, 12 Aug 2011 10:47:25 +0000</pubDate>
			<dc:creator>vashpan</dc:creator>
			<guid isPermaLink="false">110311@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi</p>
<p>I'm adding quite big amount of child nodes ( sprites to sprite batch to be exact ) every game restart and it took some time, which could be noticeable for user. ( around 0.5 - 0.8 seconds ) I'm adding about 1500 sprites, so it is quite a big number. Of course, game is still running fine on 60fps after that, even on older devices - but loading time is an issue now ( Scene is "restarting" every 'game over', and game overs are very often in this game - so this could be an annoying thing for user )</p>
<p>Of course I'm writing this post for a reason ;) I've checked in Instruments profiler and it seems that most of the loading time is spend on 'addChild' method of CCNode. So, my question is how can I optimize this process ? Any tips ? </p>
<p>Cheers! And thanks again for @riq and others for this fantastic engine, thanks to them, my next game is nearly finished.
</p></description>
		</item>
		<item>
			<title>Rob Segal on "Possible performance hit from creating/removing many CCSprite instances at once"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19520#post-109151</link>
			<pubDate>Sat, 06 Aug 2011 20:43:26 +0000</pubDate>
			<dc:creator>Rob Segal</dc:creator>
			<guid isPermaLink="false">109151@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm working on a project where I need to remove several sprites every tick.  On average this is probably around 10 sprites per tick although I haven't measured that metric accurately yet.  Just curious if anyone has experienced issues around this type of behaviour before.  I would think there is indeed a limit or scalability to how many sprites you can create/destroy in one tick without a noticeable penalty on frame rate/performance.  Was thinking of some possible solutions like creating a queue to slowly create/destroy CCSprite instances one per tick but don't know for sure if that will improve behaviour.  Any/all thoughts are appreciated.
</p></description>
		</item>
		<item>
			<title>RelicaGames on "Lots of Bullets, Lots of Enemies!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/11323#post-64118</link>
			<pubDate>Mon, 22 Nov 2010 13:19:19 +0000</pubDate>
			<dc:creator>RelicaGames</dc:creator>
			<guid isPermaLink="false">64118@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi everyone!</p>
<p>In my latest game, I have lots of enemies all firing bullets at the same time, as well as the player firing bullets at the enemies, and I've been experiencing a lot of slowdowns when they fire the bullets, and I think when the player fires bullets. So firstly I'm wondering what the best way of tracking enemies is for the player bullets.... right now I use a for (enemy in array) to track all the enemy objects in the enemy array. So is this a good way to do it? as when there are lots of enemies, and lots of bullets being fired at them, all searching through the enemy array to check for collisions, Im wondering if that causes slowdowns?</p>
<p>So basically what the player bullet is doing is this: (pseudo code)</p>
<pre><code>[self setVisible:CGRectContainsPoint(CGRectMake(cameraXPos-160-28, cameraYPos-240-28, 320+55, 480+55), self.position)];
//this bit checks visibility, so if its in the screen area, then its visible, else its not, but maybe this doesn&#39;t help with sprites in spritesheets?

position = ccpAdd(,); //for moving

CGPoint dist = ccpSub(startPoint, self.position); //this all checks if bullet has moved 500 px away from its start point
if ((dist.x*dist.x + dist.y*dist.y) &#62; 500*500)
{
   remove bullet;
}

for (enemy in array) // checking collisions for all enemies
{
      if( ccpDistance(bullet,enemy) &#60; enemy radius)
      {
      enemy hit;
      unschedule;
      remove self;
      return;
     }
}</code></pre>
<p>So maybe some of that can be done more efficiently?</p>
<p>Or maybe its the size of the bullet sprites? each one is 22x44, and part of a sprite sheet.</p>
<p>Also i do recycle bullets, by putting them in an array, and taking from that array when firing, so to reduce allocs, and to stop removing from a spritesheet so much.</p>
<p>Thanks for any help! I'm sure I must be doing something wrong as I'm sure I've seen games where theres loads of bullets flying around without and lag!! </p>
<p>Oh and I'm testing on a iTouch 1st Gen, as it would be great if everyone could play without lag! otherwise I'll have to note that this model will experience slow downs!
</p></description>
		</item>
		<item>
			<title>zedarus on "A lot of CC3LineNodes and performance optimization"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18518#post-103841</link>
			<pubDate>Sat, 09 Jul 2011 18:19:19 +0000</pubDate>
			<dc:creator>zedarus</dc:creator>
			<guid isPermaLink="false">103841@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello!</p>
<p>For my current project I need to create around 300 billboard 'particles' with some of them connected with lines in 3D (around 150-200 lines average). 300 billboard particles are rendered without any problems on 60 fps, however when I add lines I get 25 fps top. :-(</p>
<p>Are there any possible ways to optimize lines drawing in cocos3d?</p>
<p>Thanks!
</p></description>
		</item>
		<item>
			<title>pushxtonotdie on "Mysterious Performance Issue"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18614#post-104402</link>
			<pubDate>Tue, 12 Jul 2011 18:33:20 +0000</pubDate>
			<dc:creator>pushxtonotdie</dc:creator>
			<guid isPermaLink="false">104402@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a tick method that calls a function 'obstacleCollided'. In that function I create one object and pull another from an object pool. I have created two timers to measure the nanoseconds taken, one in the inner function 'buildPrefab' which creates the objects, and in the outer function obstacleCollided. Here is the bizarre results:</p>
<pre><code>inner function: executionTime to create prefab = 0.000513
outer function: executionTime to create obstacle testExplode = 0.006012
and again:
inner function: executionTime to create prefab = 0.000514
outer function: executionTime to create obstacle testExplode = 0.007961</code></pre>
<p>So somehow it creates my objects and sets everything up in 500 nanoseconds, then 6-7ms later it finally returns to the outer function:<br />
<pre><code>// inner function
-(MyObject*)buildPrefab
{
	NSDate* methodStart = [NSDate date];
	MyObject* myObject = [self createStuffDoingSomething];
	NSDate *methodFinish = [NSDate date];
	NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:methodStart];
	NSLog(@&#34;inner function: executionTime to create prefab = %f&#34;, executionTime );
	return myObject;
}

// outer function
- (MyObject*) obstacleCollided
{
	NSDate* methodStart = [NSDate date];
	KataEntity* obstacleDestruction = [self.prefabController buildPrefab];
	NSDate *methodFinish = [NSDate date];
	NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:methodStart];
	NSLog(@&#34;[CH] outerfunction: executionTime to create obstacle testExplode = %f&#34;, executionTime);
}</code></pre>
<p>I cannot seem to reproduce outside Cocos2D. Has anyone seen behavior similar to this? Am I doing something wrong?</p>
<p>Thanks!<br />
Chris
</p></description>
		</item>
		<item>
			<title>itlgames on "Sorting CCArray"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/10202#post-58487</link>
			<pubDate>Sat, 09 Oct 2010 00:01:48 +0000</pubDate>
			<dc:creator>itlgames</dc:creator>
			<guid isPermaLink="false">58487@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Has any one come with a solution to sort the CCArray? So far we can't use the <strong>sortUsingSelector</strong>, I think, so I had to do my own sorting method:</p>
<pre><code>void merge(CCArray *a, CCArray *b, int lo, int mi, int hi)
{
	int i, i1 = lo, i2 = mi + 1; // sub-array indexes
	for (i = lo; i &#60;= hi; i++) // for each element in destination b
	{
		if (i1 &#62; mi) // if i1 is out of bounds, copy from i2
			[b replaceObjectAtIndex: i withObject: [a objectAtIndex: i2++]];
		else if (i2 &#62; hi) // if i2 is out of bounds, copy from i1
			[b replaceObjectAtIndex: i withObject: [a objectAtIndex: i1++]];
		else if ((int)([[a objectAtIndex: i1] performSelector:compareFunction
			withObject: [a objectAtIndex: i2]])
				 == NSOrderedAscending) // if (a[i1] &#60; a[i2]) copy from i1
			[b replaceObjectAtIndex: i withObject: [a objectAtIndex: i1++]];
		else // if (a[i1] &#62;= a[i2]) copy from i2
			[b replaceObjectAtIndex: i withObject: [a objectAtIndex: i2++]];
	}
	// copy back b into a --&#62; same as [a setArray: b];
	for (i = lo; i &#60;= hi; i++)
		[a replaceObjectAtIndex: i withObject: [b objectAtIndex: i]];
}

void divideAndMerge(CCArray *a, CCArray *b, int lo, int hi)
{
	int mi = (lo + hi) / 2; // calculate middle point
	if (lo &#62;= hi) return; // size is 1 or less --&#62; done
	divideAndMerge(a, b, lo, mi); // sort lower half
	divideAndMerge(a, b, mi+1, hi); // sort upper half
	merge(a, b, lo, mi, hi); // merge back sorted halves
}

void mergeSort(CCArray *array, SEL selector)
{
	compareFunction = selector;

	CCArray *buffer = [array copy]; // helper buffer
	int n = [array count]; // number of items in array
	divideAndMerge(array, buffer, 0, n-1); // sort everything
	[buffer release]; // release the helper buffer
}</code></pre>
<p>To use it, just:</p>
<p><code>mergeSort(objects, @selector(compare:));</code></p>
<p>I also had to add one new method to the latest version of CCArray:</p>
<pre><code>- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject {
	[self insertObject:anObject atIndex:index];
	[self removeObjectAtIndex: index+1];
}</code></pre>
<p>Problem is, part of my bottleneck performance is on the sorting, so I'm wondering if there is a better way of doing this.
</p></description>
		</item>
		<item>
			<title>Zee on "Slow Performance"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18493#post-103713</link>
			<pubDate>Sat, 09 Jul 2011 00:30:41 +0000</pubDate>
			<dc:creator>Zee</dc:creator>
			<guid isPermaLink="false">103713@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've been bulding a game and as i started finished creating a new level, the level was very slow. The framerate for the rest of the game was 60fps but in this level, it drops to 30fps whenever the touch function is called.<br />
The only addition i made was the addition of three sprites that i got from an additional 512x512 spritesheet.<br />
I commented out these sprites and the speed returns to 60 when the touch function is called also, so i understand that these are the problems.<br />
and i thought that the game would only slow down when adding the sprites but just them remaining in the scene takes away from the speed also?<br />
any suggestions on how to fix?
</p></description>
		</item>
		<item>
			<title>jjay on "CCLayerColor kills performance on retina"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18494#post-103718</link>
			<pubDate>Sat, 09 Jul 2011 01:26:31 +0000</pubDate>
			<dc:creator>jjay</dc:creator>
			<guid isPermaLink="false">103718@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have a game at 60fps, but as soon as I display one to three screen-sized CCLayerColors, the fps plummets on the iPhone 4 (it's fine on the 3GS).  I'm guessing it's because there are twice as many pixels to render on retina.</p>
<p>Is there any way to optimize CCLayerColor to perform better?  I'm actually using CCLayerGradient, but simplifying the problem here by referring to CCLayerColor since that seems to be where the problem is.</p>
<pre><code>// Create a new cocos2d project, enable retina in the delegate,
// and paste this code as the hello world init
// Performs poorly on iPhone 4 with retina enabled, but 60fps without retina and on 3GS
-(id) init
{
	if( (self=[super init])) {		

		// I&#39;d never add this many in practice, this just simulates the problem
		for (int i = 0; i &#60; 15; i++) {
			ccColor4B color = ccc4(200, 200, 200, 255);
			CCLayerColor* backgroundGradient1 = [CCLayerColor layerWithColor:color];
			[backgroundGradient1 setOpacity:200];
			backgroundGradient1.contentSize = [[CCDirector sharedDirector] winSize];
			[self addChild:backgroundGradient1];
		}

		CCLabelTTF *label = [CCLabelTTF labelWithString:@&#34;Hello World&#34; fontName:@&#34;Marker Felt&#34; fontSize:64];
		[label setColor:ccBLACK];
		CGSize size = [[CCDirector sharedDirector] winSize];
		label.position =  ccp( size.width /2 , size.height/2 );
		[self addChild: label];

		id move = [CCMoveBy actionWithDuration:1 position:ccp(100, 100)];
		[label runAction:[CCRepeatForever actionWithAction:[CCSequence actions:move, [move reverse], nil]]];

	}
	return self;
}</code></pre></description>
		</item>
		<item>
			<title>itlgames on "CCSpriteBatchNode vs CCTMXLayer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/18182#post-101979</link>
			<pubDate>Thu, 30 Jun 2011 16:19:26 +0000</pubDate>
			<dc:creator>itlgames</dc:creator>
			<guid isPermaLink="false">101979@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm running an experiment to test some performance, I am creating an isometric grid of 18x18 tiles using first a normal CCSpriteBatchNode and adding the CCSprites to the batchnode, then using a TMX map.</p>
<p>On the TMX map I get 60fps stable on an iPod 1G, but with the CCSpriteBatchNode I get around 40-50fps bit jumpy (both with kGameAutorotationNone by the way), using cocos2d v1.0.0-rc3 reorder sprites branch.</p>
<p>Since the TMXLayer used on the TMX map extends the CCSpriteBatchNode, I'm trying to understand why the difference on performance? Anyone have any idea why? I have been comparing both classes but can't really understand what makes the TMXLayer faster :'(</p>
<p>Code is really simple, from a blank template:</p>
<p>[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"tiles.plist"];<br />
CCSpriteBatchNode *batchtiles = [CCSpriteBatchNode batchNodeWithFile:@"tiles.png"];<br />
[self addChild:batchtiles z:1];</p>
<pre><code>for (int x=-9; x&#60;18; x++) {
        for (int y=-9; y&#60;18; y++) {
                CCSprite *tile = [CCSprite spriteWithSpriteFrameName:@&#34;tilegrass1.png&#34;];
                CGPoint screenPos = [self mapToScreenPosition: x yPos: y];
                float xPos = screenPos.x;
                float yPos = screenPos.y - ((tile.contentSize.height - 35.0f) / 2.0f);

                [tile setPosition:ccp(xPos, yPos)];
                [batchtiles addChild:tile];

        }
}</code></pre>
<p>and </p>
<pre><code>CCTMXTiledMap *tileMap = [CCTMXTiledMap tiledMapWithTMXFile:@&#34;tiledmap.tmx&#34;];
[self addChild:tileMap];
CGSize s = [[CCDirector sharedDirector] winSize];
[tileMap setPosition:ccp(-s.width/2, -s.height/2)];</code></pre></description>
		</item>
		<item>
			<title>nchea1986 on "Performance issue while rapidly changing CCSprite opacity"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/17852#post-100190</link>
			<pubDate>Tue, 21 Jun 2011 15:29:33 +0000</pubDate>
			<dc:creator>nchea1986</dc:creator>
			<guid isPermaLink="false">100190@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi All,</p>
<p>I am currently facing a performance related issue in the development of my app.  Essentially, I have three CCSprites (png) which need to have their opacities changed very rapidly (roughly once every 1/10th second indefinitely). The general idea behind this is to maintain a sort of random 'flicker' on these three sprites. Currently, the way I am handling this, is to call [self scheduleUpdate] on my Node, and then modify the opacities of the sprites in the 'update' method after .1 seconds has passed.  When I run the application, the effect I am going for is achieved perfectly, however my framerate drops to ~35 FPS and stays there so long as I am viewing that node.  It never degrades any further than this, so I am fairly confident that I am not suffering a memory leak, but most likely I am going about this in a way that is just plain inefficient and using too much processing power.  <em>My question is: is there an alternative way to approach this concept that would be more efficient, or is there an alternative way to code my current concept more efficiently so that I don't incur these same framerate drops?</em></p>
<p>Seeing as the built in particle generator handles multiple copies of a png and rapidly adjusts the opacity, scale, etc. of these copies, I think this sort of thing should be possible.  Any idea would be greatly appreciated!</p>
<p>FYI, the PNGs are roughly 200px X 200px viewed on an iPhone 4 retina display, so (100pts X 100pts) and they contain a gradient with some alpha transparency on the edges.</p>
<p>Sudo code of my current solution looks like the following:</p>
<pre><code>float timeDif = 0.0f;
CCSprite *s1;
CCSprite *s2;
CCSprite *s3;

-(id) init{
	/*
	 * Add sprites to the screen and position them...
	 */
	 s1 = [CCSprite spriteWithFile:@&#34;myFileName.png&#34;];
	 s2 = [CCSprite spriteWithFile:@&#34;myFileName.png&#34;];
	 s3 = [CCSprite spriteWithFile:@&#34;myFileName.png&#34;];

	 s1.position = ccp(0,0);
	 s1.opacity = 125;
	 s2.position = ccp(100,0);
	 s2.opacity = 125;
	 s3.position = ccp(200,0);
	 s3.opacity = 125;

	 [self addChild:s1];
	 [self addChild:s2];
	 [self addChild:s3];

	//Schedule the update
	[self scheduleUpdate];
}

- (void) update:(ccTime)deltaTime{

	timeDif += deltaTime;

	if(timeDif &#62;= .1){ //If at least 1/10th second has passed
		int rand1 = arc4random() % 25;
		int rand2 = arc4random() % 25;
		int rand3 = arc4random() % 25;

		int posNeg1 = arc4random() % 2;
		int posNeg2 = arc4random() % 2;
		int posNeg3 = arc4random() % 2;

		if(posNeg1 == 1){
			s1.opacity = 125-rand1;
		}else{
			s1.opacity = 125+rand1;
		}

		if(posNeg2 == 1){
			s2.opacity = 125-rand2;
		}else{
			s2.opacity = 125+rand2;
		}

		if(posNeg3 == 1){
			s3.opacity = 125-rand3;
		}else{
			s3.opacity = 125+rand3;
		}
	   //Reset time dif counter to 0
		timeDif = 0.0f;
	}
}</code></pre></description>
		</item>
		<item>
			<title>EmperiorEric on "Performance hiccups putting a dampener on my day."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/17755#post-99653</link>
			<pubDate>Sat, 18 Jun 2011 01:28:46 +0000</pubDate>
			<dc:creator>EmperiorEric</dc:creator>
			<guid isPermaLink="false">99653@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey everyone, I've been developing this game for about a month now. Its turned out pretty fun, and it runs alright. But for a game this simple it should run like butter. So I was wondering if anyone has a few performance tips, and if anyone is available maybe some iChat and code skims to see if you notice any stupid mistakes I may have made.</p>
<p>Just to make sure we are on the same page:</p>
<p>I already use CCSpriteSheets. I try to keep my allocing to a minimum ofcourse. All Sounds are preloaded before the game. I learned to keep network interaction out of the game and only on game over so right now it just locally caches stats and achievements during gameplay.</p>
<p>If you can think of anything I should be doing, or if you're willing to connect with me on iChat and delve a bit deeper I'd love and appreciate the help.</p>
<p>iChat: BarBarianBob68</p>
<p>Thanks everyone!
</p></description>
		</item>

	</channel>
</rss>

