Hello,
I have this problem that I can't find a solution to.
I'm trying to do a simple game tutorial, with SFML 2.5 and Visual Studio 2019. But when I draw my screen, the .png textures that I load do not show as transparent background. Tried different png files. Same problem. No error.
Here is the code. Help !?!
#include <stdio.h>
#include <SFML/Graphics.hpp>
//Using
using namespace sf;
int main()
{
//Create video mode
VideoMode vm(1920, 1080);
//Create and open window
RenderWindow window(vm, "Game-x", Style::Fullscreen);
sf::ContextSettings settings = window.getSettings();
Texture textureBackground;
Texture textureSpaceShip1;
textureBackground.loadFromFile("background/background.png");
textureSpaceShip1.loadFromFile("sprites/spaceship2.png");
Sprite spriteBackground;
spriteBackground.setTexture(textureBackground);
spriteBackground.setPosition(0, 0);
Sprite spriteSpaceShip1;
spriteSpaceShip1.setTexture(textureSpaceShip1);
spriteSpaceShip1.setScale(0.2, 0.2);
spriteSpaceShip1.setPosition(100, 100);
while (window.isOpen())
{
//Player input
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
window.close();
}
//Update screen
//Draw screen
window.clear(); //clear last game screen
//Draw elements
window.draw(spriteBackground);
window.draw(spriteSpaceShip1);
//Show new game screen
window.display();
}
return 0;
}
Thank you!