Mar 23, 2013 at 5:52am UTC
the program runs like is should, but when you close it this pops up - Unhandled exception at 0x772115de in Pong 2.exe: 0xC0000005: Access violation reading location 0xfeeefef6.
I think it has to do with these global objects? I'm using SFML 2.
Tower.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
class Tower
{
public :
sf::RectangleShape TowerSpr;
sf::Vector2i TowerVector;
Tower();
~Tower();
};
extern std::vector<Tower> Towers;
extern bool clicked;
extern int towerCount;
extern sf::Vector2f CurrentBoxSizeVector;
extern sf::Text BoxCount;
extern sf::Text BoxColor;
extern sf::Text BoxSizeX;
extern sf::Text BoxSizeY;
extern sf::Text ChangeSize;
extern sf::Text PreviewBoxSizeXChange;
extern sf::Text PreviewBoxSizeYChange;
void TowerPushback(sf::RenderWindow& Window);
void TowerDraw(sf::RenderWindow& Window);
void UI(sf::RenderWindow& Window);
void SetSize(sf::RenderWindow& Window);
void SetColor(sf::RenderWindow& Window);
static inline std::string int2Str(int x);
I'll post more if you need more. There's only 3 files to the project.
Thanks a bunch :)!
Last edited on Mar 23, 2013 at 5:52am UTC
Mar 23, 2013 at 8:12am UTC
Can ~Tower() run safely after main has ended? Best is probably to avoid having global variables.
Mar 23, 2013 at 8:29am UTC
What do you mean run safely after main has ended?
I've heard that I shoudn't, but I don't know why/how I'd do it another way.
Mar 24, 2013 at 2:46pm UTC
Bump please. I don't know how i'd dothis with global variables.
Mar 24, 2013 at 2:55pm UTC
Do not use global SFML objects. It will definitely cause you problems. From what I can see there, it is most likely the sf::Text variables that are the problem.
Last edited on Mar 24, 2013 at 2:57pm UTC
Mar 24, 2013 at 3:00pm UTC
Maybe if you do post code...
In the meanwhile, show a backtrace.
Mar 24, 2013 at 4:46pm UTC
Thanks, Cire. how would I fix it then?
Show code for what...? If you ask what part I'll give you it. What's a backtrace?