Package org.newdawn.slick

Examples of org.newdawn.slick.Animation


   * @return An animation parsed from the spritesheet
   */
  private Animation buildAnimationFromFrames(SpriteSheet sheet, int row,
      int[] frames, int frameDuration, boolean flipHorizontal,
      boolean flipVertical) {
    Animation animation = new Animation(false);
    for (int frameIndex : frames) {
      Image img = sheet.getSubImage(frameIndex, row);

      if (flipHorizontal || flipVertical) {
        img = img.getFlippedCopy(flipHorizontal, flipVertical);
      }
      animation.addFrame(img, frameDuration);
    }
    return animation;
  }
View Full Code Here


                            frames[k] = tiledMap.getTileSet(0).tiles.getSubImage(sheetX + Integer.valueOf(tiledMap.getTileProperty(tileID, "frame" + String.valueOf(k + 1), "-1")), sheetY);
                            if (tiledMap.getTileProperty(tileID, "transparent", "-1").equals("1")) {
                                frames[k].setAlpha(0.6f);
                            }
                        }
                        animations.add(new Animation(frames, Integer.valueOf(tiledMap.getTileProperty(tileID, "duration", "-1"))));
                    }
                }
            }
        }
        return animations;
View Full Code Here

    }
  }

  public Animation animation(String string) {
    try {
      return new Animation(new SpriteSheet(fRootDir + "/" + string + ".png", 32, 32), 100);
    } catch (Exception e) {
      System.err.println("Couldn't find resource: " + string);
      return null;
    }
  }
View Full Code Here

    ammo = new Image("img/spearamm.gif",false,Image.FILTER_NEAREST);
 
    ammonum = new SpriteSheet(new Image("img/spearammn.gif",false,Image.FILTER_NEAREST), 32, 32);
    cutscene = new SpriteSheet(new Image("img/stry.png",false,Image.FILTER_NEAREST), 320, 240);

    playerWalk = new Animation(new SpriteSheet(new Image("img/playerwalk.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    playerAttack = new Animation(new SpriteSheet(new Image("img/playerattack.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    playerAttack.setLooping(false);
    deerWalk = new Animation(new SpriteSheet(new Image("img/deerwalk.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    deerAttack = new Animation(new SpriteSheet(new Image("img/deerattack.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    deerAttack.setLooping(false);
    bearWalk = new Animation(new SpriteSheet(new Image("img/bearwalk.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    bearAttack = new Animation(new SpriteSheet(new Image("img/bearattack.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    bearAttack.setLooping(false);
    heart =  new Animation(new SpriteSheet(new Image("img/heart.gif",false,Image.FILTER_NEAREST), 32, 32),200);
    spearWalk = new Animation(new SpriteSheet(new Image("img/playerwalkspear.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    spearFly = new Animation(new SpriteSheet(new Image("img/spearfly.gif",false,Image.FILTER_NEAREST), 32, 32),300);
    spearAttack = new Animation(new SpriteSheet(new Image("img/spearthrow.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    spearAttack.setLooping(false);
    playerDyin = new Animation(new SpriteSheet(new Image("img/pldyn.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    playerDyin.setLooping(false);
    deerDyin = new Animation(new SpriteSheet(new Image("img/deerdyn.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    deerDyin.setLooping(false);
    bearDyin  = new Animation(new SpriteSheet(new Image("img/beardyn.gif",false,Image.FILTER_NEAREST), 32, 32),100);
    bearDyin.setLooping(false);

    plStep = new Sound("snd/plStep.wav");
    deerStp = new Sound("snd/deerwlk.wav");
    bearStp= new Sound("snd/berWalk.wav");
View Full Code Here

    tileOffsetY = (int) ((tileY - posY) * TyrelionMap.TILE_SIZE)
  }
 
  public void loadAnimations(String animation) {
    animations = new Animation[12];
    Animation running_up = new Animation();
    Animation running_down = new Animation();
    Animation running_left = new Animation();
    Animation running_right = new Animation();
    Animation standing_up = new Animation();
    Animation standing_down= new Animation();
    Animation standing_left = new Animation();
    Animation standing_right = new Animation();
    Animation talking_up = new Animation();
    Animation talking_down= new Animation();
    Animation talking_left = new Animation();
    Animation talking_right = new Animation();
    animations[ANIM_RUNNING_UP] = running_up;
    animations[ANIM_RUNNING_DOWN] = running_down;
    animations[ANIM_RUNNING_LEFT] = running_left;
    animations[ANIM_RUNNING_RIGHT] = running_right;
    animations[ANIM_STANDING_UP] = standing_up;
    animations[ANIM_STANDING_DOWN] = standing_down;
    animations[ANIM_STANDING_LEFT] = standing_left;
    animations[ANIM_STANDING_RIGHT] = standing_right;
    animations[ANIM_TALKING_UP] = talking_up;
    animations[ANIM_TALKING_DOWN] = talking_down;
    animations[ANIM_TALKING_LEFT] = talking_left;
    animations[ANIM_TALKING_RIGHT] = talking_right;
    setAnimation(ANIM_STANDING_DOWN);
   
    File root = new File("res/anim/"+animation);
    File[] categories = root.listFiles();
   
    if (categories != null){
      for (File category : categories) {
        if (category.isDirectory() && !category.isHidden()) {
          File[] anims = category.listFiles();
          for (File elem : anims) {
            File[] images = elem.listFiles();
            if (images != null) {
              for (File image : images) {
                if (image.isFile() && !image.isHidden()) {
                  if ("running".equals(category.getName())) {
                    try {
                      if ("up".equals(elem.getName())) {
                        running_up.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                      if ("down".equals(elem.getName())) {
                        running_down.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                      if ("left".equals(elem.getName())) {
                        running_left.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                      if ("right".equals(elem.getName())) {
                        running_right.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                    } catch (SlickException e) {
                      e.printStackTrace();
                    }
                  } else if ("standing".equals(category.getName())) {
                    try {
                      if ("up".equals(elem.getName())) {
                        standing_up.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                      if ("down".equals(elem.getName())) {
                        standing_down.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                      if ("left".equals(elem.getName())) {
                        standing_left.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                      if ("right".equals(elem.getName())) {
                        standing_right.addFrame(new Image(image.getAbsolutePath()), 90);
                      }
                    } catch (SlickException e) {
                      e.printStackTrace();
                    }
                  } else if ("talking".equals(category.getName())) {
                    try {
                      if ("up".equals(elem.getName())) {
                        talking_up.addFrame(new Image(image.getAbsolutePath()), 180);
                      }
                      if ("down".equals(elem.getName())) {
                        talking_down.addFrame(new Image(image.getAbsolutePath()), 180);
                      }
                      if ("left".equals(elem.getName())) {
                        talking_left.addFrame(new Image(image.getAbsolutePath()), 180);
                      }
                      if ("right".equals(elem.getName())) {
                        talking_right.addFrame(new Image(image.getAbsolutePath()), 180);
                      }
                    } catch (SlickException e) {
                      e.printStackTrace();
                    }
                  }
View Full Code Here

    topOffsetInTiles = heightInTiles / 2;
    leftOffsetInTiles = widthInTiles / 2;
   
    // create the player sprite based on a set of sprites from the sheet loaded
    // above (tank tracks moving)
    player = new Animation();
    for (int frame=0;frame<7;frame++) {
      player.addFrame(sheet.getSprite(frame,1), 150);
    }
    player.setAutoUpdate(false);
View Full Code Here

  public void init(GameContainer container) throws SlickException {
    image = new Image("testdata/rocket.png");
    back = new Image("testdata/sky.jpg");
    font = new AngelCodeFont("testdata/hiero.fnt","testdata/hiero.png");
    SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
    homer = new Animation(sheet, 0,0,7,0,true,150,true);
  }
View Full Code Here

   
    sheet = new PackedSpriteSheet("testdata/testpack.def", Image.FILTER_NEAREST);
    rocket = sheet.getSprite("rocket");
   
    SpriteSheet anim = sheet.getSpriteSheet("runner");
    runner = new Animation();
   
    for (int y=0;y<2;y++) {
      for (int x=0;x<6;x++) {
        runner.addFrame(anim.getSprite(x,y), 50);
      }
View Full Code Here

   */
  public void init(GameContainer container) throws SlickException {
    this.container = container;
   
    SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
    animation = new Animation();
    for (int i=0;i<8;i++) {
      animation.addFrame(sheet.getSprite(i,0), 150);
    }
    limited = new Animation();
    for (int i=0;i<8;i++) {
      limited.addFrame(sheet.getSprite(i,0), 150);
    }
    limited.stopAt(7);
    manual = new Animation(false);
    for (int i=0;i<8;i++) {
      manual.addFrame(sheet.getSprite(i,0), 150);
    }
    pingPong = new Animation(sheet, 0,0,7,0,true,150,true);
    pingPong.setPingPong(true);
    container.getGraphics().setBackground(new Color(0.4f,0.6f,0.6f));
  }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.Animation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.