Hiho Community =)
I've got a problem with deleting sprites. My current programm looks like this:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
using namespace std;
int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");
sf::Image* Image = new sf::Image();
if(!Image->LoadFromFile("sprite.png"))
{
cout<<"Sprite konnte nicht geladen werden"<<endl;
}
sf::Sprite* Sprite = new sf::Sprite((*Image));
Sprite->SetPosition(0, 0);
while(App.IsOpened())
{
sf::Event Event;
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed || (Event.Type==sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape))
{
App.Close();
}
if(Event.Type == sf::Event::KeyPressed && Event.Key.Code==sf::Key::A)
{
delete Image;
Image = NULL;
delete Sprite;
Sprite = NULL;
}
}
App.Clear();
App.Draw((*Sprite));
App.Display();
}
return EXIT_SUCCESS;
}
Now when i press 'A' and want do delete the image and the sprite the programms hanging up. I'm able to destroy the image alone, but when i'm destroying the sprite it's hanging up and i don't know why
I'm using code blocks with the ms vc++ 2008 compiler and downloaded the newest version of sfml for vc++ 08, the libraries i added are sfml-graphics.lib and sfml-window.lib, otherway i can't compile. The Build Target is Release.
I hope someone can help me =)
MfG Killmichnich
PS: Sorry for my bad english, i'm not very goot at it =(