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

Author Topic: Transparancy and Animations Help??  (Read 1995 times)

0 Members and 2 Guests are viewing this topic.

masterassassin1398

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Transparancy and Animations Help??
« on: October 08, 2014, 07:34:49 pm »
Hello all, I have been working on a little 8-bit game recently and i have been struggling with animations and actually making my sprites have a transparent background.  For the animations i have tried to loop through some images but it runs too quickly for that.  If anyone has any tips that would be greatly appreciated.  However for the transparency i went to the documentation for color and into my code put this:
sf::Color transparent(192, 192, 192);
transparent.a = 0;

Now on my texture i use this exact same rgb combination and it turns out to be a light gray.  However i am using microsoft paint and i dont really want to use anything else like photoshop because i dont know how to use it.  Again if anyone has some recommendations for me to correct me and guide me on the right path it would be greatly appreciated.  I can also give more code if needed to see.  Thank you.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Transparancy and Animations Help??
« Reply #1 on: October 08, 2014, 08:04:46 pm »
So, unless you use a graphics program that supports transparency, you're stuck. You could choose a color that you won't ever use, and make that the background of each image.
Then, load the file as an sf::Image, not an sf::Texture.
Use createMaskFromColor to turn that color transparent.
Then load a sf::Texture from the sf::Image. And you'd be good to go.

Xornand

  • Jr. Member
  • **
  • Posts: 78
  • C++ / Python
    • View Profile
Re: Transparancy and Animations Help??
« Reply #2 on: October 08, 2014, 08:20:28 pm »
Hello all, I have been working on a little 8-bit game recently and i have been struggling with animations and actually making my sprites have a transparent background.  For the animations i have tried to loop through some images but it runs too quickly for that.  If anyone has any tips that would be greatly appreciated.
Don't progress to the next frame on every game loop update. Instead, set some time interval (i.e. 200 milliseconds) before progressing to the next animation frame.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Transparancy and Animations Help??
« Reply #3 on: October 08, 2014, 08:33:03 pm »
For animations: unless you want to reinvent the wheel, you could simply use Thor :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

masterassassin1398

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Transparancy and Animations Help??
« Reply #4 on: October 08, 2014, 08:51:00 pm »
Thank you guys =)