Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Need to set alpha of an image - and my game with SFML  (Read 5203 times)

0 Members and 1 Guest are viewing this topic.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Need to set alpha of an image - and my game with SFML
« on: October 24, 2012, 12:39:08 pm »
Hello Ladies and Guys from the Forum
I m Pablo from Bs As Argentina, I made a Mario Bros game with C# and SDL, then I moved to SFML cos in SDL didn t work the direct input functions and had no support for C#, and I needed to use Threading and ignore the Events ...
Since yesterday I have been translating the SDL code to SFML ... there were 800 errors, now remain 6, that are about the Alpha component ... I dont know and couldnt find how to set the alpha value to an image (to all its pixels) ... and I need this for the ilumination in some levels of my game
Something like
image.Alpha = 128;  //(and all the pixels should be ARGB(128, R, G, B))
or whatever it is the syntax
Thank you
Then when I solve this I ll send my game for you
Pablo

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Need to set alpha of an image - and my game with SFML
« Reply #1 on: October 24, 2012, 01:00:31 pm »
Changing the pixels of the image itself would be too heavy and unneccessary. With today's graphics cards and APIs, a better strategy is to change the overall color of the sprite that uses the image -- this is a free operation (handled by the graphics card), and this way you can have several sprites that all use the same image but with different colors.

So you need to change the Color property of your Sprite object (set it to Color(255, 255, 255, alpha) if you only want to set the alpha).
Laurent Gomila - SFML developer