I see you can set a sprite's color, but is there anything to shift a color hue (similar to photoshop hue/saturation)? Example use would be for a character, change a hue instead of tinting the whole sprite a different color.
Shifting color hue
(10 posts) (7 voices)-
Posted 2 years ago #
-
This article might be worth looking into.
http://lukehatcher.com/2009/04/coloring-sprites-with-cocos2d-iphone/
I think it is similar to what you are wanting to do.
Posted 2 years ago # -
Thanks, good info there, but it looks to be doing the same thing as using setColor, which tints the whole sprite. Actually the mario image at the top of that article is exactly what I am trying todo, notice the mario skincolor remains the same and the red hat/clothes is the only thing changed.
Posted 2 years ago # -
Hmm, not for sure then I haven't messed with sprite color very much.
Posted 2 years ago # -
@friken, it seems that with opengl es 1.1, you can only remove a composant from red, green, and blue but you cannot add. That's a pity because by adding colors to the texture we could make almost everything we want. But I'm not an opengl guru, and maybe some of them on this forum can help on this.
Posted 2 years ago # -
This is just a guess, but could you have two sprites, one for the clothes and one for the flesh with different transparences, one on top of the other? Then just tint the clothes sprite.
Posted 2 years ago # -
Well, seems to me you would need three of them. I don't know any way to make both red turn to white AND brown turn to green using a single color transformation.
Posted 2 years ago # -
For now I've just created sprites for each color I want as I need skin-tones to remain the same. I would guess you could make a per-pixel routine that would check if one component of an rgb is above/below a threshold and shift just it, but I'm not wanting to dive that deep into this one when a 5 minute photoshop job make a couple alternate tiny sprites does the trick.
Posted 2 years ago # -
I worked on a game where we needed to be able to have specific skin colors, similar to what you're talking about, but there was no way we could include N number of assets for each possible color (since the color was user-selectable). Instead, we included a single "skin" asset and did color replacement by actually loading up the image and looping through the pixels. It was effective but relatively slow on older devices (you don't want to be doing it for more than a couple 64x64 images).
Right now, though, I'm trying to find a good way to do do color translation in cocos2d on a sprite. Preferably I'd like to be able to use a color matrix akin to what I'd do in Actionscript, but it sounds like this is a restriction with OpenGL rather than cocos...
Posted 1 year ago # -
do you have implement it? I encountered the same problem.help!
Posted 6 months ago #
Reply
You must log in to post.