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

Author Topic: Trouble with textures  (Read 1390 times)

0 Members and 1 Guest are viewing this topic.

Tomaszlek

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Trouble with textures
« on: January 28, 2018, 07:30:33 pm »
That's my first topic on this forum and I have trouble with this error and I don't know how it fix.
There's the code:
#include <stack>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include "game.h"
#include "game_state.h"
#include "texture_manager.h"
using namespace sf;
void Game::loadTextures()
{
    menedzertekstur.loadTexture(background, "RTS/tlo_menu.png");
}
and
void TextureManager::loadTexture(const std::string& name, const std::string& filename)
{
    /* Load the texture */
    sf::Texture tex;
    tex.loadFromFile(filename);

    /* Add it to the list of textures */
    this->textures[name] = tex;
    return;
}
public:

    /* Add a texture from a file */
    void loadTexture(const std::string& name, const std::string &filename);
class Game
{
private:
    void loadTextures();

    public:
    stack<GameState*> states;

    RenderWindow window;
    TextureManager menedzertekstur ;
    Sprite background;
« Last Edit: January 28, 2018, 07:32:11 pm by Tomaszlek »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Trouble with textures
« Reply #1 on: January 28, 2018, 07:38:14 pm »
And what's the error/issue? :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tomaszlek

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Trouble with textures
« Reply #2 on: January 28, 2018, 08:09:55 pm »
The error is: no matching function for call to 'TextureManager::loadTexture(sf::Sprite& const char[17])

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Trouble with textures
« Reply #3 on: January 28, 2018, 08:47:00 pm »
You declared loadTexture as private member function, thus it's not accessible from the outside.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tomaszlek

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Trouble with textures
« Reply #4 on: January 28, 2018, 09:41:25 pm »
So what should I change in this code because I don't know(I've learned C++ since 4 months and SFML since 2 weeks but I know I'm stupid)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Trouble with textures
« Reply #5 on: January 28, 2018, 10:22:44 pm »
Go back to just C++ and learn more. In 4 months you have barely touched the basics. If you don't know the difference between a public and private member function, then there's more to learn first, before diving into a library that requires you to have a basic understanding of C++.

I can't stop you from playing around with SFML, but keep in mind that the SFML forum isn't here to teach you C++, it's not even here to teach you SFML, but it's here to help you and support you using SFML. Plus the huge catalog of threads may give you solutions to problems you may run into.
For general C++ questions use StackOverflow or similar.

As for your problem, get your C++ book and read or hopefully re-read the section about access specifiers. ;)
« Last Edit: January 28, 2018, 11:25:40 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tomaszlek

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Trouble with textures
« Reply #6 on: January 28, 2018, 11:08:30 pm »
Well, your advice will help me,maybe it's too early for me to write games in SFML, surely I go back to my C ++ book (very good indeed, written by Jerzy Grębosz). I have already understand the error in the code and I fixed it but I think it's better that I have to learn C ++ for about next half a year and then start writing games seriously. Thank you and best regards