I was wondering how do animation using a sprite sheet. I have a sprite sheet and the size is height:400 width:601
The code I am using is:
#include<SFML/Graphics.hpp>
#include<iostream>
#include <string>
int main() {
sf::RenderWindow Window;
Window.create(sf::VideoMode(980, 760), "Game Engine");
sf::Texture Ptexture;
sf::Sprite playerImage;
if (!Ptexture.loadFromFile("spritesheetIdle.png")) {
std::cout << "error file not found\n";
}
playerImage.setTexture(Ptexture);
while (Window.isOpen()) {
sf::Event Event;
while (Window.pollEvent(Event)) {
switch (Event.type)
{
case sf::Event::Closed:
Window.close();
break;
}
}
Window.draw(playerImage);
Window.display();
}
}
If you could then can you please try to explain me about sf:IntRect()
too?