Hey,
I have a slight problem with a project I'm working with. For starters I'll throw in the background info.
I'm using cocos2d v0.99.0-rc, iPhone SDK 3.1.2 and mostly the Simulator (occasionally a old iPod Touch,
naturally at 3.1.2 firmware). I run the game mostly in Debug mode, on the Simulator and the iTouch.
How the game is setup:
-1 Scene
-1 Layer (created by the scene)
-BoardLayer (has 70 TileSprites + background + gui/hud)
- 70 TileSprites (saved in a SpriteSheet and all use the spriteSheetRendering)
-TileSprites are randomly generated
-Screenshot: http://dl.dropbox.com/u/816458/screenie.png
-Source: http://dl.dropbox.com/u/816458/TestCase.zip (graphics are placeholders, but cause the same problem
as with the normal ones)
The BoardLayer consist of a background image which is a child of the Layer, and the background image has a
SpriteSheet as a child. We add Tiles to the SpriteSheet and then scroll the background so the tiles scroll
with the background aswell.
So what is the problem? FPS... as showed in the screenshot, the FPS is rather low (in debug mode AND release).
So any optimization tips are welcomed with open arms and a cheery smile! What I've tested so far is I turned
off the "Compile for Thumb" option in the project since I found some reference to that on these forums
(http://www.cocos2d-iphone.org/archives/26). Though this does not help the Simulator, I do get a noticeable
upgrade in FPS on the iTouch device (around 40 to 50fps).
The cause for the FPS drop, atleast the reason I suspect, is the GUI/HUD (the borders). Since one way to get
better fps is to disable the GUI (can be done by commenting out [self initGUI]; call from BoardLayer's init),
so this way you get a constant 60fps. I first thought the problem was that I was using one picture for the
borders (guiframe1.png in the src, has just borders and the middle is alphaed out) but I tried with 4 pieces
(left, right, bottom and top) as the borders and still got the same FPS decrease. Second thing I tried was
to add every sprite into one file (the source is for this) but that didn't give any FPS boost over the previous
way of having two layers, one for the board and one for the GUI/HUD.
I'm a starting game developer so I'm a wee bit clueless on some rendering (atleast OpenGL ES is a new friend for
me) stuff so do correct me if I'm wrong here, but I assume everything is drawn, not just the visible stuff.
I mean the i.e. the background bits behind the Tiles, possible Tiles behind the GUI's borders etc?
Another question that came into mind is, can you create different sized layers? Considering the screenshot
again and the bit with the groovy bright Tiles (the Board), could that be made as a smaller layer (sized
290x408) and just updating stuff there? Mmm, with updating I mean that those Tiles are supposed to scroll down
with the background (which will be around 290x2000 in size later). Also, which is a better idea, scroll every
tile on its own with CCMoveBy or have them as the child of the background and moving just the background (currently
would be done like this?
Also, memory management... if I have a CCLayer (BoardLayer), which has a CCSprite (background image) as a child,
which has a CCSpriteSheet as a child AND that thing has like 70 TileSprites as children... what is the correct
order in releasing these? Been mostly using Java and Python so I'm still learning correct memory management,
thus needing to ask that question, since children freak me out when doing memory management :) I suppose I just
need to release the parent, and that will deal with the kids? Or do I need to release everything by hand?
A lot of questions from an information hungry person :)
Cheers,
Pete