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 03-03-2011, 08:58 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 1
pfredette is on a distinguished road
Question Dynamically change color of sprites

I need help please!

I am developing an iPhone game where there will be multiple sprites of different colors. These sprites are completely identical in form and animation, except for their color. So basically:
bad guy#1 is red with a black hat
bad guy#2 is blue with a black hat
bad guy#3 is white with a white hat
bad guy#4 is orange with a green hat
etc.

Problem:
There are 120 animations for the sprites and 10 different color variations. That would mean managing and coding 1200 sprite sheets if the process were done manually.

Additional Challenge:
It's not just about changing 1 color in each sprite because:
There are 4 colors that need to change on each sprite.
The portion where the color changes moves in the sprite.

Solution needed:
What would be the best solution to deal with this issue through programming. I don't want to have 1200 sprite sheets (i.e. 120 sprite sheets for EACH color variation). I would like to have the colors change dynamically.

Thanks!
pfredette is offline   Reply With Quote
Old 03-03-2011, 09:32 AM   #2 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

OpenGL allows you to set the color tint of each vertex. Each of your sprites would have to consist of several quads (pairs of triangles really) with different vertex colors for each quad. You'd have to use a single texture atlas/sprite sheet for this to draw in one call.

If you're using Cocos2D then you can still set the color of individual sprites - so each of your characters would have to be a node with several tinted sprites as children.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 04-19-2011, 09:34 AM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 11
fazalyazdan is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
OpenGL allows you to set the color tint of each vertex. Each of your sprites would have to consist of several quads (pairs of triangles really) with different vertex colors for each quad. You'd have to use a single texture atlas/sprite sheet for this to draw in one call.

If you're using Cocos2D then you can still set the color of individual sprites - so each of your characters would have to be a node with several tinted sprites as children.
Yes i am using cocos2d but please give me a single example of this that how can i do this.
fazalyazdan is offline   Reply With Quote
Old 04-19-2011, 10:00 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

here an example of what you want to do
Coloring Sprites with Cocos2d-iPhone - Cheetah Lurk
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
color, dynamically, sprite

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: 424
7 members and 417 guests
chemistry, ChrisYates, hussain1982, Retouchable, skrew88, SLIC, 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:13 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0