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.


Topics - affenmehl8

Pages: [1]
1
Graphics / My texture holder gets deleted although still in scope
« on: June 13, 2019, 04:37:30 pm »
So I'm new to SFML. I read a lot of post, but I really  don't get it.
I wrote an texture holder:
Quote
class tile_texture_holder {
private:
   sf::Texture tx;
public:
   tile_texture_holder(type a) {
      switch (a) {
      case type::desert:
         tx.loadFromFile("C:/Users/Andreas/source/repos/conquer/Media/desert.png");
         break;
      case type::grass:
         tx.loadFromFile("C:/Users/Andreas/source/repos/conquer/Media/grass.png");
         break;
      case type::mountain:
         tx.loadFromFile("C:/Users/Andreas/source/repos/conquer/Media/mountain.png");
         break;
      case type::water:
         tx.loadFromFile("C:/Users/Andreas/source/repos/conquer/Media/water.png");
         break;
      }
   }
   sf::Texture ret_texture() {
      return tx;
   }

   ~tile_texture_holder() {
      std::cout << "///////////////////////HOLDER DELETED!!!/////////////////////" << std::endl;
   }
};

And I tried to load a sprite with it in different ways....
For example:
Quote
tile_texture_holder t(type::desert);
      sf::Sprite s;
      s.setTexture(t.ret_texture());
(in the same function, where I draw the sprite)
I always get the white box being drawn. And I really dont get why the texture_holder is getting deleted.
BTW type is an enum.

I hope somebody can help me solve my issue!

2
Window / Window doesn't finish loading and is not responding to input
« on: June 10, 2019, 10:45:30 pm »
Hello fellas!

I'm new to SFML so my problem is maybe stupid. I made a main menu and my problem is that if I start the program I get this loading mouse icon and the programm isn't responding to my input. The input is checked in another than the menu class so maybe thats my problem but I'm not sure.
Here's my code:

menu header:
(click to show/hide)

main:
(click to show/hide)


I hope somebody can help me. And yes, sorry for ugly code. I'm just playing around.

Pages: [1]