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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - JohnnyMccrum

Pages: [1]
1
General / All sprites showing as white boxes.
« on: May 05, 2016, 05:23:42 pm »
Not sure what I'm doing wrong here.

when I display my textures with

Quote
window.draw(Spritesheet.at(1));

they all appear as white squares.

I have these variables in my main.h


Quote
//the main spritesheet.

Image sheetIMG;

//array to hold circles.
vector<CircleShape> Circles;

//array to hold sprites.
vector<Sprite> Spritesheet;

below is the offending code.




Quote
int LoadSpritesheet()
{
   //make sure spritesheet exists, then loads it into an image.

   Texture sheet;
   if (!sheet.loadFromFile("Sprites/A.png"))
   {
      return 0;
   }
   else
   {
      sheetIMG = sheet.copyToImage();
      MakeSprites();
      return 1;
   }
      

}

void MakeSprites()
{
   //turns the entire spritesheet into 8x8 modular sprites.

   Texture tex;

   int c = 0, r = 0;

   for (int i = 0; i <= (sheetIMG.getSize().x * sheetIMG.getSize().y) / 64; i++)
   {

      if (i == 125)
      {

         Sprite sprsdsds;
      }

      if (!tex.loadFromImage(sheetIMG, IntRect(0, 0, 8, 8)))
         break;
      else
      {
              Sprite spr;
              spr.setTexture(tex);
         Spritesheet.push_back(spr);
         c += 8;
         if (c == 16) { r++; };

      }
   }
   
   

         
}

Pages: [1]