Hey guys,
I'm trying to display some simple text and im getting weird errors, now this piece of code works
gEntity.h
#ifndef g_Entity_H
#define g_Entity_H
//includes
#include "g_Rec.h"
#include "g_Image_Manager.h"
#include <iostream>
#include <string>
//Game Includes
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
class gEntity{
private:
sf::Sprite tex;
bool spr,txt,btn;
rect pos;
sf::Font fontStyle;
sf::Text textDisplay;
public:
gEntity();
void setup(int id, gImageManager& imgManage);
sf::Sprite rtnTex(){return tex;}
bool rtnSpr(){return spr;}
bool rtnTxt(){return txt;}
bool rtnBtn(){return btn;}
rect rtnPos(){return pos;}
void intText(int set);
void stringText(std::string set);
sf::Text rtnText(){return textDisplay;}
};
#endif
//skip alot of the cpp file
case 1:
{
fontStyle.loadFromFile("arial.ttf");
//textDisplay.setFont(fontStyle);
textDisplay.setString("Booty Swag");
textDisplay.setPosition(100,100);
spr = false; btn = false; txt = true;
break;
gState code just to draw stuff
for(int i = 0; i < entities.size(); i++ )
{
if (entities.at(i).rtnBtn() == true)
{
}
if (entities.at(i).rtnTxt() == true)
{
screen.draw(entities.at(i).rtnText());
}
if (entities.at(i).rtnSpr() == true)
{
screen.draw(entities.at(i).rtnTex());
}
}
now this works fine, but if i close my window sometimes it will stay status is 0 or a random number and throw a error as i close, and the other error is if i uncomment the line which sets the font style at the draw method for the rtnText it displays memory violation... im using SFML 2.0, can anyone help me out?
Cheers