Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-17-2011, 10:03 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 44
lootcorp is on a distinguished road
Default Cocos2D and sprites - separate images or spritesheet?

Hi all -

I'm messing around with Cocos2D on a proof of concept, and I have a question about sprite performance.

I will be creating a number of sprites to represent game pieces on the gameboard. They are similar to Scrabble tiles, where each tile looks identical except for the letter on the front.

I'm trying to think of the best way to accomplish this - I have thought of three options so far:

1. Create a separate PNG file and sprite for each gamepiece
2. Create a spritesheet containing all possible gamepieces, and load them from the spritesheet
3. Create a blank gamepiece PNG and attach a label of some kind as a child to the sprite to display the gamepiece's value


Which would you recommend? What is the performance hit of #1 vs #2? I expect to have anywhere between 8 and 24 gamepieces displayed on screen at any given time.

#3 is the least work intensive for me, but I worry that I might have limited formatting options with the label and may not be able to get the gamepieces to look correctly (nicely rendered gamepiece with a cheesy-looking text label slapped on top)

Thanks,

Jim
lootcorp is offline   Reply With Quote
Old 02-17-2011, 12:05 PM   #2 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 69
AndreaT is on a distinguished road
Default

I think a good choice is to make a separate spritesheet for each layer... ex. HUD,gamesprite...

If i can remember well you can assign a different Z only if the sprites are in different CCSpriteSheet...

I also can suggest to search zwoptex on google and read some tutorial about this app.
AndreaT is offline   Reply With Quote
Old 02-17-2011, 12:09 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 44
lootcorp is on a distinguished road
Default

Quote:
Originally Posted by AndreaT View Post
I think a good choice is to make a separate spritesheet for each layer... ex. HUD,gamesprite...

If i can remember well you can assign a different Z only if the sprites are in different CCSpriteSheet...

I also can suggest to search zwoptex on google and read some tutorial about this app.
Thanks, it seems sprite sheets are the way to go here. I'm checking out both Zwoptex and TexturePacker - Ray Wenderlich's site has some great tutorials on using both.

How To Use Animations and Sprite Sheets in Cocos2D | Ray Wenderlich

How to Create and Optimize Sprite Sheets in Cocos2D with Texture Packer and Pixel Formats | Ray Wenderlich
lootcorp is offline   Reply With Quote
Old 03-01-2011, 04:14 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 336
mochibits is on a distinguished road
Default

I purchased Zwoptex based on some reviews, and I can say that it is easy to use, and works seamlessly with Cocos2d.

I also dont think it has to be a different spritesheet. I am able to assign different Z's with everything on one spritesheet.
mochibits is offline   Reply With Quote
Old 03-01-2011, 10:10 AM   #5 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 2
bweberapps is on a distinguished road
Default

You definitely want to use as few spritesheets as possible. This will greatly improve memory usage and performance. Textures on the iPhone can only be loaded with their width and height having to be a power of two, so 2, 4, 8, 16 up to 1024 on older devices and 2048 on newer devices. This means if you have a texture at 66x66 it will have to load a 128x128 texture to fit it in, which almost quadruples the memory usage. So make your spritesheets in powers of two, like 512x1024 and put as many sprites as you can on it. Also put sprites that will be used in the same scenes on the same sheets, you don't want to have to load a second 1024x1024 spritesheet just to use one sprite image from it.
bweberapps is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 427
9 members and 418 guests
7twenty7, chemistry, ChrisYates, hussain1982, Retouchable, skrew88, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:11 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0