Sign in to follow this  

How to change all the colors of a sprite in SDL

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have been thinking for a while how to display collisions in the game that I'm developing. At the end I have decided to show the sprite in white flashing with the real frame for a couple of seconds, like many games do. My question is... is there a way to display a frame in a specific color in SDL? I wouldn't like to start duplicating all the frames in white color... That would be a lot. Thanks

Share this post


Link to post
Share on other sites

If I understand you correctly, by "sprite flashing in white" you mean that pixels that aren't alpha / colorkey in sprite, cycle their color in order: normal color / white, yes? Or do you mean, just normal white rectangular border ("frame") around sprite?

AFAIK there's no special SDL function that will do the first one for you, so you should copy sprite in realtime to second surface (or precache it on startup) and use direct pixel access to change colors in two for loops.

Share this post


Link to post
Share on other sites
uhmm... I thought it was going to be easier. Yes, what I meant was to cycle their color in order (normal color / white).

At this moment, I don't know what to do, maybe I should show collisions in a different way...

Share this post


Link to post
Share on other sites

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this