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.


Messages - gustav9797

Pages: [1]
1
General / [SOLVED] Spritesheet algorithm not working
« on: February 10, 2013, 10:44:12 pm »
This is the current code we use to convert one image full of blocks to seperated ones, but we only get a white block. Using sfml 1.6.

How we use it:
Code: [Select]
Initializer:
if(AddSpriteSheet(std::string("BlockSolid.png"), 16, 16))
{
std::cout << "its working, cheese-pie.";
}
PlayState.cpp:
Code: [Select]
sf::Sprite* tempSprite = tc.getTexture(std::string("BlockSolid.png"));
playerSprite = &(tempSprite[0]);
TextureContainer.cpp:
Code: [Select]
bool TextureContainer::AddTexture(std::string &fileName)
{
sf::Image image;
bool success = image.LoadFromFile(fileName);
sf::Sprite *sprite = new sf::Sprite();
sprite->SetImage(image);
textureMap.emplace(fileName, sprite);

return success;
}

bool TextureContainer::AddSpriteSheet(std::string &fileName, int spriteWidth, int spriteHeight)
{
sf::Image image;
bool success = image.LoadFromFile(fileName);

int width = image.GetWidth()/spriteWidth;
int height = (image.GetHeight()/spriteHeight);

sf::Sprite *sprite = new sf::Sprite[width*height];

sf::Image tempImage(16, 16);

for (int x = 0; x+1 <= width; x++)
{
for (int y = 0; y+1 <= height; y ++)
{
tempImage.Copy(image, 16, 0, sf::IntRect(x*spriteWidth, y*spriteHeight, (x + 1)*spriteWidth, (y + 1)*spriteHeight), true);
sprite[x+y*width].SetImage(tempImage);
}
}
textureMap.emplace(fileName, sprite);
return success;
}

2
System / Re: static class sf::Time const sf::Time::Zero error
« on: June 25, 2012, 03:43:24 pm »
Thanks (Omg how could I miss that)!

3
System / Re: static class sf::Time const sf::Time::Zero error
« on: June 25, 2012, 03:35:49 pm »
Static,
linker: sfml-network.lib, sfml-system.lib, sfml-graphics.lib
preprocessor: SFML_STATIC

4
System / static class sf::Time const sf::Time::Zero error
« on: June 25, 2012, 03:19:57 pm »
Hi, using SFML 2.0 rc, Windows 7 64bit

1>test2.obj : error LNK2001: unresolved external symbol "public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)
1>C:\Users\Gustav\Documents\Visual Studio 2010\Projects\test2\Release\test2.exe : fatal error LNK1120: 1 unresolved externals

..

Pages: [1]
anything