|
|
|
@ -24,8 +24,7 @@ public class EntitySprite {
|
|
|
|
private TextureRegion[][][] regions;
|
|
|
|
private TextureRegion[][][] regions;
|
|
|
|
private int[] frames;
|
|
|
|
private int[] frames;
|
|
|
|
private int attackState;
|
|
|
|
private int attackState;
|
|
|
|
|
|
|
|
private int die;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 0: links, 1: rechts
|
|
|
|
// 0: links, 1: rechts
|
|
|
|
private int direction;
|
|
|
|
private int direction;
|
|
|
|
@ -34,11 +33,11 @@ public class EntitySprite {
|
|
|
|
sprites = new Sprite[1];
|
|
|
|
sprites = new Sprite[1];
|
|
|
|
regions = new TextureRegion[1][][];
|
|
|
|
regions = new TextureRegion[1][][];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 0: idle, 1: walking, 2: attack, 3: die
|
|
|
|
// 0: idle, 1: walking, 2: attack
|
|
|
|
frames = new int[4];
|
|
|
|
frames = new int[3];
|
|
|
|
|
|
|
|
direction = 0;
|
|
|
|
direction = 0;
|
|
|
|
attackState = 0;
|
|
|
|
attackState = 0;
|
|
|
|
|
|
|
|
die = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < sprites.length; i++){
|
|
|
|
for(int i = 0; i < sprites.length; i++){
|
|
|
|
regions[i] = TextureRegion.split(textures[i], width, height);
|
|
|
|
regions[i] = TextureRegion.split(textures[i], width, height);
|
|
|
|
@ -58,7 +57,10 @@ public class EntitySprite {
|
|
|
|
|
|
|
|
|
|
|
|
direction = e.getDirection();
|
|
|
|
direction = e.getDirection();
|
|
|
|
|
|
|
|
|
|
|
|
if(attackState == 1){
|
|
|
|
if(die >= 1){
|
|
|
|
|
|
|
|
updateDie();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(attackState == 1){
|
|
|
|
updateAttack();
|
|
|
|
updateAttack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(moves){
|
|
|
|
else if(moves){
|
|
|
|
@ -70,6 +72,17 @@ public class EntitySprite {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateDie(){
|
|
|
|
|
|
|
|
if(frames[3] >= 9){
|
|
|
|
|
|
|
|
die = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
frames[3]++;
|
|
|
|
|
|
|
|
sprites[0].setRegion(regions[0][4][frames[3]]);
|
|
|
|
|
|
|
|
updateFlip();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updateAttack(){
|
|
|
|
public void updateAttack(){
|
|
|
|
frames[0] = 0;
|
|
|
|
frames[0] = 0;
|
|
|
|
frames[1] = 0;
|
|
|
|
frames[1] = 0;
|
|
|
|
@ -131,15 +144,12 @@ public class EntitySprite {
|
|
|
|
public void update(int xPos, int yPos){
|
|
|
|
public void update(int xPos, int yPos){
|
|
|
|
for(int i = 0; i < sprites.length; i++){
|
|
|
|
for(int i = 0; i < sprites.length; i++){
|
|
|
|
sprites[i].setPosition(xPos - 16, yPos);
|
|
|
|
sprites[i].setPosition(xPos - 16, yPos);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateCollision(xPos, yPos);
|
|
|
|
updateCollision(xPos, yPos);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateCollision(int xPos, int yPos){
|
|
|
|
public void updateCollision(int xPos, int yPos){
|
|
|
|
collisionSprite.setPosition(xPos, yPos);
|
|
|
|
collisionSprite.setPosition(xPos, yPos);
|
|
|
|
getFullCollisionSprite().setPosition(xPos, yPos);
|
|
|
|
getFullCollisionSprite().setPosition(xPos, yPos);
|
|
|
|
@ -158,7 +168,6 @@ public class EntitySprite {
|
|
|
|
return sprites;
|
|
|
|
return sprites;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param sprites the sprites to set
|
|
|
|
* @param sprites the sprites to set
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|