Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [solved] white sprite  (Read 1683 times)

0 Members and 1 Guest are viewing this topic.

sammynammy

  • Newbie
  • *
  • Posts: 1
    • View Profile
[solved] white sprite
« on: September 17, 2008, 06:36:57 pm »
hi everyone,

i want to draw a sprite on my screen but i just get a white rectangle.

this is my code:
Glider.h
Code: [Select]

#ifndef GLIDER_H
#define GLIDER_H

#include <SFML/Graphics.hpp>
#include "Entity.h"
//------------------------------------------------------------
class CGlider : public CEntity
{
public:
CGlider();
CGlider(const float fX, const float fY);
virtual ~CGlider();

void Initialize();
void Uninitialize();
void Draw();
void Idle(float flDeltaTime);

private:
sf::Sprite m_pSprite;
};
#endif

Glider.cpp
Code: [Select]

#include "Glider.h"
#include "core/KeyboardManager.h"
#include "Game/GameManager.h"
//-----------------------------------------------------------
extern sf::RenderWindow App;
//-----------------------------------------------------------
void CGlider::Initialize()
{
sf::Image Resource;
if(!Resource.LoadFromFile("C:/...Resourcen/Gleiter/gleiter.bmp"))
GAMEMANAGER->QuitWithError("Datei Resourcen/Gleiter/gleiter.bmp nicht gefunden");
m_pSprite.SetImage(Resource);
}
//-----------------------------------------------------------
void CGlider::Draw()
{
App.Draw(m_pSprite);
}
//-----------------------------------------------------------



this is a tutorial for coding an 2D-game.
by using the debug instruments of the VS2008 i found out that after loading the bmp-file the pixel array of the Resource object is completely white, Color(0,0,0,255) and its also displayed in white. but i just dont get my mistake.
perhabs you could help me...

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
[solved] white sprite
« Reply #1 on: September 17, 2008, 07:10:48 pm »
Resource is deleted before the sprite is drawn.
Try making Resource member data.

 

anything