Hello, I'm new to using the SFML API, and been using C++ for just a few months, with other graphics APIs, however, I've just started using arrays, and I'm having problems loading my images.
What I want to do is have an array of an specific image type (i.e. tiles) to be able to load them at start-up, and use them at will, by simply using imgTiles[tileimagenum], but I'm stuck at the loading. I keep getting this error at run-time:
http://i.imgur.com/rJzHe.pngAnd the Autos window, looks like this:
http://i.imgur.com/v1QSQ.pngHere's the code that I'm using:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>
// Image Variables //
sf::Image * imgTile;
const int tileCount = 2;
// Image Functions //
void loadImages(void)
{
std::stringstream ss;
// Tile Images //
imgTile = new sf::Image[tileCount];
for (int i = 1; i <= tileCount; i++)
{
ss << "\\Content\\Graphics\\Tiles\\" << i << ".png";
imgTile[i].LoadFromFile(ss.str());
ss.str().clear();
}
}
void destroyImages(void)
{
delete [] imgTile; imgTile = NULL;
}
// Main Function //
int main(int argc, char *argv[])
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
// Load our images.
loadImages();
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
destroyImages();
App.Close();
}
// Clear the screen (fill it with black color)
App.Clear();
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
I hope I can get some help on this, and if there's a better way of doing it, please let me know.
Regards,
Ghostly.