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 :
#include <cstdlib>
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;
int main()
{
RenderWindow window(VideoMode(600, 600), "SFML works!");
Image menu1;
Image menu2;
Sprite sm1;
Sprite sm2;
menu1.loadFromFile("img/SMenu1.bmp");
menu2.loadFromFile("img/SMenu2.bmp");
Texture m1;
Texture m2;
menu1.createMaskFromColor(Color(85,255,127));
m1.loadFromImage(menu1);
m2.loadFromImage(menu2);
m1.setSmooth(true);
m2.setSmooth(true);
sm1.setTexture(m1);
sm2.setTexture(m2);
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.clear();
window.draw(sm1);
window.display();
}
return 0;
}
I only wanted to make the image appear with a good transparency, so i used that image :
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 :
Are they other solutions that i can use to made this thing works correctly ?