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

Author Topic: Sprite Mask Problem  (Read 1319 times)

0 Members and 1 Guest are viewing this topic.

doctormiller

  • Newbie
  • *
  • Posts: 2
    • View Profile
Sprite Mask Problem
« on: September 01, 2014, 11:11:23 pm »
Hello everyone, I'm trying to learn SFML right now and i wanted to make a simple menu with a sprite image, so I made this thing :
(click to show/hide)

I only wanted to make the image appear with a good transparency, so i used that image :
(click to show/hide)

In the code it's related to
menu1.loadFromFile("img/SMenu1.bmp");

and then i applied the Mask and I smoothed the texture but in the application it's horrible like that :
(click to show/hide)

Are they other solutions that i can use to made this thing works correctly ?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Sprite Mask Problem
« Reply #1 on: September 01, 2014, 11:21:28 pm »
1) Don't smooth textures when you want things to be pixel-perfect.  Smoothing, by definition, blurs pixels together.

2) There's no reason to use an opaque image and create a mask from it.  Just make a .png image with actual transparency, and load that directly into a texture.  Your code will be much simpler:
(click to show/hide)

2a) If you don't know how to create image files with actual transparency, that's probably because MS Paint doesn't know either.  If you use a competent image editor like paint.net or GIMP, it's trivial.
« Last Edit: September 01, 2014, 11:23:02 pm by Ixrec »

doctormiller

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Sprite Mask Problem
« Reply #2 on: September 01, 2014, 11:32:42 pm »
Thanks for the help, i searched a lot and indeed making a .png file with transparency seems the best and easier way to do that, thank you again and have a nice evening !