I dont know what im doing wrong but for some reason I keep getting an unhandled exception my my entity manager. I try to draw the sprite to the screen and right before the entity manager updates and trys to draw it everything is fine. But as soon as it attempts to draw the sprite i get an exception. Here's the code. Can someone please help me ? This is driving me nuts
if you need the whole project just let me know and ill email it to you
//Game.cpp
#include "EntityManager.h"
void System::Init()
{
engine = new System();
engine -> SetWindow(800, 600, "Test");
Entity player;
player.Load("test.png", 100, 100);
manager.Add(player);
}
void System::Run()
{
sf::Event ev;
while (engine -> window -> IsOpened())
{
engine -> window -> PollEvent(ev);
engine -> window -> Clear();
manager.Update();
engine -> window -> Display();
}
}
//System.cpp
#include "System.h"
void System::SetScreenDim(int width, int height)
{
this -> SCREENW = width;
this -> SCREENH = height;
}
void System::SetTitle(std::string title)
{
this -> Title = title;
}
void System::SetWindow(int width, int height, std::string title)
{
this -> SCREENW = width;
this -> SCREENH = height;
this -> window = new sf::RenderWindow(sf::VideoMode(width, height), title.c_str());
}
//EntityManager.cpp
#include "EntityManager.h"
#include "System.h"
void Manager::Update()
{
Entity entity;
std::list<Entity>::iterator iter = eList.begin();
while (iter != eList.end())
{
entity = *iter;
entity.GetSprite().SetPosition(entity.GetX(), entity.GetY());
engine -> window -> Draw(entity.GetSprite());
iter++;
}
}
void Manager::Add(Entity entity)
{
eList.push_back(entity);
}
//Entity.cpp
#include "Entity.h"
void Entity::Load(std::string filename, float x, float y)
{
this -> Filename = filename;
this -> Image.LoadFromFile(this -> Filename.c_str());
this -> Sprite.SetImage(this -> Image);
this -> posx = x;
this -> posy = y;
}
void Entity::Update()
{
this -> Sprite.SetPosition(this -> posx, this -> posy);
}
[/code]