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

Author Topic: Trying to draw sprites, but they appear white.  (Read 1743 times)

0 Members and 1 Guest are viewing this topic.

CookiePusherPro

  • Newbie
  • *
  • Posts: 1
    • View Profile
Trying to draw sprites, but they appear white.
« on: July 02, 2011, 01:38:12 am »
So I have class tykk:

public:

Code: [Select]
public:
tykk(void);
~tykk(void);
void drawIt(sf::RenderWindow&);

sf::Image a;
sf::Sprite pilt;

tykk::tykk(void)
{
a.LoadFromFile("aare.png");
pilt.SetImage(a);
}
void tykk::drawIt(sf::RenderWindow& rw){

rw.Draw(pilt);

}


class kaart:

Code: [Select]
class kaart
{

public:

tykk sisu[60][40];
kaart(int,int);
kaart(void);
~kaart(void);
};

kaart::kaart()
{

int a;
tykk b;

for(int i=0; i<60;i++){
for(int j=0; j<40;j++){

a = sf::Randomizer::Random(1,4);
if(a==1){
tykk b;
sisu[i][j]=b;

}







}
}
}






and in main i have:

Code: [Select]

sf::RenderWindow a(sf::VideoMode(800,600,32),"TT");
kaart krt;
for(int i=0;i<60;i++){
for(int j=0;j<40;j++){
krt.sisu[i][j].pilt.SetPosition(i*15,j*15);
krt.sisu[i][j].drawIt(a);
}
}
a.Display();


I tried to paste only the important parts of code. Im using 1.6. I get no errors, but it doesn't draw the "aare.png", it just leaves everything white.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Trying to draw sprites, but they appear white.
« Reply #1 on: July 02, 2011, 05:53:21 am »
1. This doesn't have any of the information we need. In fact, I am positive I know the problem, but I need more code to confirm it.
2. We need complete and minimal code that still shows the problem, complete meaning it can be compiled on its own, and minimal meaning it fits in one file and ONLY has code relevant to the problem.
I use the latest build of SFML2

Haikarainen

  • Guest
Trying to draw sprites, but they appear white.
« Reply #2 on: July 02, 2011, 07:34:50 am »
+1 on above poster, but the problem probably is either that the image cant be found, or that  you dont save the sf::Image you apply to the sprite.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Trying to draw sprites, but they appear white.
« Reply #3 on: July 02, 2011, 10:35:12 am »
Everything is explain in the tutorial, see §Images and sprites management from http://www.sfml-dev.org/tutorials/1.6/graphics-sprite.php .
SFML / OS X developer