Animacio 2p
This commit is contained in:
parent
279c401f4d
commit
770739c352
5 changed files with 3 additions and 3 deletions
|
@ -26,16 +26,16 @@ void Character::update(float deltaTime){
|
||||||
timestamp += deltaTime;
|
timestamp += deltaTime;
|
||||||
if (timestamp >= frameTime){
|
if (timestamp >= frameTime){
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
|
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||||
|
setTextureRect(rect);
|
||||||
|
|
||||||
|
//Acabar automaticament la animacio de attack
|
||||||
if (actualState == PlayerState::attacking and indexX >= 3){
|
if (actualState == PlayerState::attacking and indexX >= 3){
|
||||||
setState(PlayerState::idle);
|
setState(PlayerState::idle);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
indexX = (indexX+1)%4;
|
indexX = (indexX+1)%4;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
|
||||||
setTextureRect(rect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
Reference in a new issue