Hello, I've been trying to figure this one out, I have a function that loops through an array of pointers to classes which have sprites, and then tells the Render Window to draw them. I'm not sure whats wrong, but whenever the line
Window.Draw(Array[X][Y]->BlockSprite);
is in the function (or a similar line anywhere else) the sfml render window will crash. When this line is not there, it is fine.
Here is the code for the function, and ask if there is anything else I can give you guys, thanks in advance.
Square * Array[23][23];// class Square has sf::Sprite BlockSprite;
void DrawManager()
{
for (int X = 0; X < 24; X = X + 1)
{
for (int Y = 0; Y < 24; Y = Y + 1)
{
if (Array[X][Y] != 0)
{
Window.Draw(Array[X][Y]->BlockSprite);
}
}
}
}
The pointers are set to zero if they are not pointing to anything, so its fairly self explanatory what this does... I think XD
Also, originally this was written so that the sprite was private and there was a public function that returned it, I got rid of it in troubleshooting and made the sprite public