• Advertisement
Sign in to follow this  

Alpha blending in SDL_Rect

This topic is 4328 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

I'm making a card game and have picked out every cards x and y positions and width/height with SDL_Rect. Now I want the cards to become transparent when I click on them, I managed to make the whole card surface transparent with all 5 cards on the screen, but didn't managed to make only one card transparent. Is there any way to do so? I want something that indicates that the card is selected and making it transparent is a perfect thing to do so. If not possible, is there anything else I can use to make the card look like it's selected?

Share this post


Link to post
Share on other sites
Advertisement
Yes that's possible. Assuming you have a SDL_Surface that represents the card you need to be transparent, it's simply a matter of calling SDL_SetAlpha to set alpha blending on and off for a whole surface, and specify the amount of transparency. How the alpha blending takes place depends on the kind of source and destination surface and some other stuff, so you may need to play with it a bit or look at the documentation for what you want.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement