Sep 19, 2012 at 1:01am UTC
I'm writing the engine for a game and I'm getting to the part where I start drawing the map and giving textures to objects. But I can't seem to get past this one error. Can anyone help?
This is my Engine.cpp file where I'm getting the error
void Engine::LoadTextures()
{
sf::Texture texture;
texture.loadFromFile("sprite1.png");
TextureManager .AddTexture(texture);
testTile = new Tile(TextureManager .GetTexture(0));
}
This is my TextureManager.h file
#ifndef TEXTURE_MANAGER_H
#define TEXTURE_MANAGER_H
#include <SFML/Graphics.hpp>
#include <vector>
using namespace std;
class TextureManager
{
private:
vector<sf::Texture> textureList;
public:
TextureManager();
~TextureManager();
void AddTexture(sf::Texture& texture);
sf::Texture& GetTexture(int index);
};
#endif
And this is my TextureManager.cpp file
#include "TextureManager.h"
#include <SFML\Graphics.hpp>
TextureManager::TextureManager()
{
}
TextureManager::~TextureManager()
{
}
void TextureManager::AddTexture(sf::Texture& texture)
{
textureList.push_back(texture);
}
sf::Texture& TextureManager::GetTexture(int index)
{
return textureList[index];
}
Any help would be greatly appreciated. I'm about ready to rip my hair out lol
Last edited on Sep 19, 2012 at 1:02am UTC
Sep 19, 2012 at 1:04am UTC
Are you including texturemanager.h into the engine.h file?
Sep 19, 2012 at 1:05am UTC
Yeah texturemanager is included
Sep 19, 2012 at 1:08am UTC
Is the object TextureManager defined in class Engine?
Sep 19, 2012 at 1:41am UTC
In these statements
TextureManager.AddTexture(texture);
testTile = new Tile(TextureManager.GetTexture(0));
TextureManager is not an object. You should create an object of type TextureManager that to call its non-static function members.
Last edited on Sep 19, 2012 at 1:41am UTC
Sep 19, 2012 at 12:27pm UTC
Thank you so much! Everything works perfectly now!