1
Window / Re: Recommended way to change mouse cursor
« on: March 31, 2020, 06:42:49 pm »
Thank you I will try much appreciated.
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.
// Couple of ways to do it.
// #1 Player position is the same as his previous position
if(playerPos == prevPlayerPos){
// change animation to idle
}
// #2 Player velocity = 0, player is not moving
if(playerVel.x == 0 && playerVel.y == 0){
// change animation to idle
}
#3
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
// change animation to left
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
// change animation to right
}
else{
// change animation to idle
}
}
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
window.setVerticalSyncEnabled(true);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event)){
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
return 0;
}