SFML community forums
Help => Graphics => Topic started by: stevend on August 11, 2009, 07:44:21 am
-
ok so here is my code:
(i am using the resource manager to manage images found in the wiki)
sf::Image* image = gImageManager.getResource( tilesetfilelocation );
if( image != NULL )
{
sf::Sprite sprite;
sprite.SetImage( *image );
sprite.SetSubRect(sf::IntRect(32, 32, 32, 32));
sprite.SetCenter(0,0);
sprite.SetPosition((float)32,(float)32);
map.push_back(sprite);
}
else
cout << "File not found! " << tilesetfilelocation << endl;
my problem is that when is when i comment out this, and draw all the sprites (map is a vector array of sprites)
sprite.SetSubRect(sf::IntRect(32, 32, 32, 32));
it draws the entire image fine. but when i attempt to draw one tile from this by leaving the above line UNcommented i get nothing.
i cant get SetSubRect to work for the life of me.
the image i am using is a tile set with 32x32 tiles in jpg format, one used by rpgmaker.
any ideas?
-
Just read the documentation of sf::IntRect please ;)
-
could you possibly provide a link? and a little help?
ive searched through the doxygen and all i could find was a page on sf::Rect and it didnt reeally help me what so ever.
thanks, any help is appreciated.
-
Sure :)
http://www.sfml-dev.org/documentation/1.5/classsf_1_1Rect.htm#0f19f5cf78eb52f122b904fb258acfce
As you can see it's not (x, y, width, height) but (left, top, right, bottom).
-
wow now i feel like a dumbass :roll: thanks for the help