CHaracter que no funxiona

This commit is contained in:
marti.lloveras 2017-01-21 03:18:55 +01:00
parent 0b8bc0afd7
commit 0364fa8ef0
2 changed files with 17 additions and 3 deletions

View file

@ -5,8 +5,11 @@ Character::Character(){
ASSERT(texture.loadFromFile(spriteFile));
height = texture.getSize().y;
width = texture.getSize().x;
next = 0;
next = timestamp = indexX = indexY = 0;
setTexture(texture);
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
setTextureRect(rect);
actualState = previousState = PlayerState::idle;
}
void Character::update(float deltaTime){
@ -26,15 +29,24 @@ void Character::update(float deltaTime){
}
else {
indexX = 0;
if (actualState == PlayerState::idle)
if (actualState == PlayerState::idle){
indexY = 1;
actualState = PlayerState::attacking;
}
else if (actualState == PlayerState::attacking)
else if (actualState == PlayerState::attacking){
indexY = 0;
actualState = PlayerState::idle;
}
}
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
setTextureRect(rect);
}
}
void Character::setState(PlayerState::playerState state){
previousState = actualState;
actualState = state;
}

View file

@ -4,9 +4,11 @@
class Character : public sf::Sprite{
private:
//CONSTS
const double frameTime = 0.2;
const int numFrames = 4;
const std::string spriteFile = "";
//CONSTS
int indexX, indexY, width, height;
int posX, posY;