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

Author Topic: problem with SetSubRect  (Read 2696 times)

0 Members and 2 Guests are viewing this topic.

stevend

  • Newbie
  • *
  • Posts: 20
    • View Profile
problem with SetSubRect
« 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)

Code: [Select]

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)

Code: [Select]

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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
problem with SetSubRect
« Reply #1 on: August 11, 2009, 07:55:34 am »
Just read the documentation of sf::IntRect please ;)
Laurent Gomila - SFML developer

stevend

  • Newbie
  • *
  • Posts: 20
    • View Profile
problem with SetSubRect
« Reply #2 on: August 11, 2009, 08:03:03 am »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
problem with SetSubRect
« Reply #3 on: August 11, 2009, 08:06:38 am »
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).
Laurent Gomila - SFML developer

stevend

  • Newbie
  • *
  • Posts: 20
    • View Profile
problem with SetSubRect
« Reply #4 on: August 11, 2009, 04:58:34 pm »
wow now i feel like a dumbass  :roll:  thanks for the help

 

anything