views:

188

answers:

1

I am developing a game in which i have 10-12 sprite moving at a time in one scene can that slow down the simulator? in my game if i click on sprite moving at top i.e. plane from which humans jump down. so if one click continuously 6 or 7 times at time 6 or 7 sprites appear and it slow down. i have not tested on iphone but its slow down's simulator. m using scheduler to move all images. does it affect.

+1  A: 

Having a lot of sprites can slow down the simulator as well as the iPhone.

This is because the texture buffer needs to be swapped out a lot. This is an expensive operation.

Consider using AtlasSprite instead. They are much faster. Even if your sprites use different images, consider putting them in one texture and then use the AtlasSpriteManager and AtlasSprite to draw them to the screen.

Also, if you have 10 sprites with the same Texture2D object it speeds things up (but only if they are rendered without swapping the texture buffer, which can be a pain to optimize.)

Using a scheduler to move them should be fine.

nash
Ok nash thanx I will try it. I thought using scheduler is might be the coz.
amy
i m changing images of sprites using texture only sp=giftBody->data; sp.texture=[[TextureMgr sharedTextureMgr]addImage:[NSString stringWithFormat:@"elf%d.png",k+1]]; giftBody->data=sp;here giftbody is a shape. so they r not with same texture. can i use one texture2d object for all. how to use atlasSprites. can suggest any links where i find all explanation about it.
amy
Google turned up this tutorial: http://johnehartzog.com/2009/05/using-cocos2d-atlasspritemanager/I'm sure there are plenty other tutorials out there.The basics are: One Atlas sprite manager, many Atlas sprites. You place all your small images in one large picture. Load the large image into the manager, and then use the Atlas sprite to display them individually and/or sequentially.
nash
See also: http://www.cocos2d-iphone.org/archives/47
nash
ya those are helpful links. but now i have noticed new thing i.e. if i turn off sound of the game and then play it works fine with any no. of images. but with sound on it hangs if images are more than 6.
amy
That sounds like a strange problem. I have no experience with using sound for the iPhone. I can only recommend checking the Xcode Console and start troubleshooting from the error you'd see there.Also, try and make your code free of any Warnings, if any.Simplify some code. Change things around a bit, to try and understand what is going wrong.
nash