getter
This commit is contained in:
parent
350c07715d
commit
1184a03f5f
3 changed files with 18 additions and 9 deletions
|
@ -3,14 +3,14 @@
|
|||
Character::Character(int player){
|
||||
playerNum = player;
|
||||
ASSERT(texture.loadFromFile(spriteFile));
|
||||
height = texture.getSize().y/5;
|
||||
width = texture.getSize().x/5;
|
||||
next = timestamp = indexX = 0;
|
||||
height = texture.getSize().y/6;
|
||||
width = texture.getSize().x/4;
|
||||
timestamp = indexX = 0;
|
||||
indexY = magicNumber;
|
||||
setTexture(texture);
|
||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||
setTextureRect(rect);
|
||||
actualState = previousState = PlayerState::idle;
|
||||
actualState = PlayerState::idle;
|
||||
|
||||
if (playerNum == 0){
|
||||
setPosition(posX1, posY1);
|
||||
|
@ -18,7 +18,7 @@ Character::Character(int player){
|
|||
}
|
||||
else{
|
||||
setPosition(posX2, posY2);
|
||||
magicNumber = 2;
|
||||
magicNumber = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,15 +40,23 @@ void Character::update(float deltaTime){
|
|||
}
|
||||
|
||||
void Character::setState(PlayerState::playerState state){
|
||||
previousState = actualState;
|
||||
actualState = state;
|
||||
if (state == PlayerState::idle){
|
||||
indexX = 0;
|
||||
indexY = 0 + magicNumber;
|
||||
}
|
||||
else{
|
||||
else if (state == PlayerState::attacking){
|
||||
indexX = 0;
|
||||
indexY = 1 + magicNumber;
|
||||
}
|
||||
else if (false /*state == PlayerState::damaged*/){
|
||||
indexX = 0;
|
||||
indexY = 2 + magicNumber;
|
||||
}
|
||||
}
|
||||
|
||||
bool Character::isLastFrame(){
|
||||
return indexX == 3;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,14 +19,15 @@ private:
|
|||
sf::Texture texture;
|
||||
int indexX, indexY, width, height;
|
||||
int playerNum;
|
||||
PlayerState::playerState actualState, previousState;
|
||||
float timestamp, next;
|
||||
PlayerState::playerState actualState;
|
||||
float timestamp;
|
||||
|
||||
public:
|
||||
Character();
|
||||
Character(int player);
|
||||
void update(float deltaTime);
|
||||
void setState(PlayerState::playerState state);
|
||||
bool isLastFrame();
|
||||
|
||||
};
|
||||
|
||||
|
|
Binary file not shown.
Reference in a new issue