Seems, that altough I made a function for those, it now gives scope errors.
TextureManager.h:
#ifndef TEXTUREMANAGER_H_INCLUDED
#define TEXTUREMANAGER_H_INCLUDED
#include <SFML/Graphics.hpp>
using namespace std;
void loadTextures()
{
sf::Texture texture;
texture.loadFromFile("/data/textures/menu/New Game.pdn");
}
#endif // TEXTUREMANAGER_H_INCLUDED
SpriteManager.h:
#ifndef SPRITEMANAGER_H
#define SPRITEMANAGER_H
#include <SFML/Graphics.hpp>
#include "TextureManager.h"
using namespace std;
void loadSprites()
{
sf::Sprite NewGamesprite(texture);
}
#endif // SPRITEMANAGER_H
main.cpp:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>
#include "Character.h"
#include "TextureManager.h"
#include "SpriteManager.h"
using namespace std;
int main()
{
loadTextures();
loadSprites();
sf::RenderWindow window(sf::VideoMode(800, 600), "Reckon Dash.exe", sf::Style::Default);
cout <<"Window open"<<endl;
// run the program as long as the window is open
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.clear();
window.display();
window.draw(NewGamesprite);
}
return 0;
}
in the loadsprites it says that texture was not declared in this scope and in main.cpp it says that NewGamesprite was not declared in this scope. How to fix??