I keep getting runtime errors around the line,
m_Game->m_Window.Draw(*m_BackGround);
Please help, I'm utterly confused.
m_BackGround is a Sprite*
namespace DE
{
SplashState::SplashState() :
cGameState()
{
}
SplashState::~SplashState()
{
Cleanup();
}
void SplashState::Init(cGameEngine* game)
{
m_Game = game;
sf::Sprite bg;
sf::Image* image = gImageManager.getResource("../data/images/background.jpg");
//sf::Sprite bg(image);
if( image != NULL)
{
bg.SetImage( *image );
}
m_BackGround = &bg;
m_BackGround->SetPosition(m_Game->m_Window.GetWidth()/2,m_Game->m_Window.GetHeight()/2);
m_StartButton = new cp::cpButton(&m_Game->m_Window, &m_Game->m_GUIContainer, "Start", 100, 100, 60, 30);
}
void SplashState::Cleanup()
{
delete m_StartButton;
delete m_Game;
m_StartButton = NULL;
m_Game = NULL;
}
void SplashState::Pause()
{
}
void SplashState::Resume()
{
}
void SplashState::HandleEvents()
{
}
void SplashState::Update()
{
}
void SplashState::Draw()
{
m_Game->m_Window.Draw(*m_BackGround);
m_StartButton->Draw();
}
} //namespace DE
I have my states in an array of cGameState pointers after being told the vector moves around in memory and may screw the address of my image up.
This is how I call the state in my main loop
m_sStack[CURRENT_STATE]->Draw();