When I do this the tank is drawn only
as a white rectangle in the top left.
What's wrong?
Here is my CTank.h:
#ifndef __CTANK_H__
#define __CTANK_H__
class CTank
{
public:
CTank ();
~CTank ();
int LoadImages ();
public:
sf::Sprite *tanksprite;
};
#endif
Here is my CTank.cpp
#include <SFML/Graphics.hpp>
#include "CTank.h"
CTank::CTank ()
{
tanksprite = new sf::Sprite;
}
CTank::~CTank ()
{
}
int CTank::LoadImages ()
{
sf::Image Image;
if (!Image.LoadFromFile("../graphic/tank2.png"))
return EXIT_FAILURE;
tanksprite->SetImage (Image);
return 0;
}
Here is my Main:
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include "CTank.h"
int main()
{
CTank *tt = new CTank;
tt->LoadImages ();
// Create the main window
sf::RenderWindow App(sf::VideoMode(800, 600), "Test Tank");
// Start the game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close ();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close ();
}
App.Draw (*tt->tanksprite);
// Update the window
App.Display ();
}
return EXIT_SUCCESS;
}