Hello guys! I'm just going to start off with some information. I am running Mac OS X 10.10, Xcode version 6.1.1, SFML 2.2. I am creating an app that lets you change some settings otherwise hard to change in a game, and I'm having a issue. I'm just going to say that I'm NOT a professional programmer, it's just a hobby that i've been doing for a while. I am not super good at it, so thats why I'm asking you guys!
I have a main.cpp file, which looks like this.
#include "main.h"
#include "langSelect.h"
#include "mainMenu.h"
using namespace std;
int main(int argc, char** argv){
mainMenu();
return 0;
}
It just calls the mainMenu method inside the mainMenu.h, which is just where i declare the method. In mainMenu.cpp, I'm displaying a menu with buttons and text. I declare these two variables in the beginning:
vector<sf::Text> text;
int textsNumber;
Then in the mainMenu method, i do
textsNumber = 0;
After that, i create text like this:
text.push_back(sf::Text("blahblahblah",font,30));
This can now be accessed like an array, like this:
text[0]
Now when it comes to clearing the window and drawing the text, i have a loop where it goes thought a set number (2 in this case, i only have 2 lines of text right now) of numbers in a loop. Remember that textsNumber is 0 as i set in the beginning.
while( textsNumber < 2){
window.draw(text[textsNumber]);
textsNumber++;
if(textsNumber == 2){
textsNumber = 0;
break;
}
}
If i run this, the program launches and opens a window. But instantly, Xcode comes into focus and highlights
window.draw(text[textsNumber]);
in green and displays a text beside, that says Thread 1: EXC_BAD_ACCESS (code=1, adress 0x0)
http://gyazo.com/c3ca45ae039ce6e17e9d08be008ca49aIt also does that on main.cpp:
http://gyazo.com/317e1f147c9da652413473ce46fdcfb0If i click the other tabs on the left side i see this:
http://gyazo.com/475feefd270519138c3a98a9dd424532http://gyazo.com/73e99dcf657042ab477d1ce8c8357940http://gyazo.com/d6edc312382865bdb11490b2d303ac9aWhat could cause this problem? I have been searching all over google, only to find irrelevant information or very, VERY advanced guides on how to fix. If you want to see the whole source code, just tell me. Thanks.