Here's a picture of the problem.The mouth of this character is a separate sprite and texture and when I use settexturerect it doesn't display.
To make this less confusing I removed stuff out of this script and took out the function to test settexturerect.
int main()
{
RenderWindow window(VideoMode(600, 480),"");
Texture ffhead;
ffhead.loadFromFile("ff-stat-head.png",IntRect(0,0,40,32));
Sprite sprite2;
sprite2.setTexture(ffhead);
sprite2.setPosition(300,300);
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
if(Keyboard::isKeyPressed(Keyboard::Space))
{
sprite2.setTextureRect(IntRect(40,0,40,32));
}
window.clear();
window.draw(sprite2);
window.display();
}
return 0;
}
Can you spot where my mistake is?