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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Danielsann5

Pages: [1]
1
Graphics / Re: PNG texture not transparent
« on: May 07, 2020, 06:12:17 pm »
Can't believe I made the same mistake with different png files. Thank you!

2
Graphics / Re: PNG texture not transparent
« on: May 07, 2020, 05:33:22 pm »
The background texture is ok. Because it has no transparent parts, so to say.
But the spaceship texture, has a white-gray background, instead of being transparent.

Here are the textures.

3
Graphics / PNG texture not transparent
« on: May 07, 2020, 04:49:34 pm »
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!

Pages: [1]
anything