示例#1
0
 public HeroActor(int x, int y, int heroNumber, boolean playerControlled, DankGame dankGame) {
   this.playerControlled = playerControlled;
   if (playerControlled) {
     characterList = Dank.chosenHeroesList;
   } else {
     characterList = Dank.enemyHeroesList;
   }
   pixmap = new Pixmap(64, 64, Pixmap.Format.RGBA8888);
   bitmapFont = new BitmapFont();
   bitmapFont.setColor(1, 0, 0, 1);
   this.x = x;
   this.y = y;
   this.heroNumber = heroNumber;
   this.dankGameInstance = dankGame;
   if (playerControlled == true) {
     heroSheet = characterList.get(heroNumber - 1).getCharacterSheet();
     heroFrames = new TextureRegion[4 * 3];
     TextureRegion[][] tmp = TextureRegion.split(heroSheet, 32, 32);
     int index = 0;
     for (int i = 0; i < 4; i++) {
       for (int j = 0; j < 3; j++) {
         heroFrames[index++] = tmp[i][j];
       }
     }
     TextureRegion[] standingFrames = new TextureRegion[2];
     standingFrames[0] = heroFrames[7];
     standingFrames[1] = heroFrames[8];
     standingAnimation = new Animation(1f, standingFrames);
     spriteBatch = new SpriteBatch();
   } else {
     heroSheet = characterList.get(heroNumber - 1).getCharacterSheet();
     heroFrames = new TextureRegion[1 * 1];
     TextureRegion[][] tmp = TextureRegion.split(heroSheet, 64, 64);
     int index = 0;
     for (int i = 0; i < 1; i++) {
       for (int j = 0; j < 1; j++) {
         heroFrames[index++] = tmp[i][j];
       }
     }
     standingAnimation = new Animation(1f, heroFrames);
     spriteBatch = new SpriteBatch();
   }
   setBounds(x, y, 64, 64);
   addCustomListener();
   update();
 }