Package org.newdawn.slick

Examples of org.newdawn.slick.Animation$Frame


     * @param startNumFramAnimazione - colonna da cui si parte per leggere l'animazione (da 0)
     * @param numFramAnimazione - numero di colonna da cui leggere l'animazione
     * @return
     */
    private Animation setAnimationFromSheet(SpriteSheet sheet , int rigaSheet, int startNumFramAnimazione, int numFramAnimazione){
      Animation animation = new Animation();
        for (int frame=startNumFramAnimazione;frame<numFramAnimazione;frame++) {
          animation.addFrame(sheet.getSprite(frame,rigaSheet), 150);
        }
        animation.setAutoUpdate(false);
        return animation;
    }
View Full Code Here


     * @param startNumFramAnimazione - colonna da cui si parte per leggere l'animazione (da 0)
     * @param numFramAnimazione - numero di colonna da cui leggere l'animazione
     * @return
     */
    private Animation setAnimationFromSheet(SpriteSheet sheet , int rigaSheet, int startNumFramAnimazione, int numFramAnimazione){
      Animation animation = new Animation();
        for (int frame=startNumFramAnimazione;frame<numFramAnimazione;frame++) {
          animation.addFrame(sheet.getSprite(frame,rigaSheet), 150);
        }
        animation.setAutoUpdate(false);
        return animation;
    }
View Full Code Here

            animations=new LinkedList();
    }
   
    public void addAnimation(SpriteSheet sheet,int duration){
          for(int y=0;y<sheet.getVerticalCount();y++){ 
            Animation animation=new Animation();
            for(int x=0;x<sheet.getHorizontalCount();x++){
                     animation.addFrame(sheet.getSprite(x, y), duration);
            }
            animation.setAutoUpdate(true);
            animations.add(animation);
          }
        setAnimation(0);
    }
View Full Code Here

  }

  protected void updateAnimation(int delta) {
    if (animations != null) {
      if (currentAnim != null) {
        Animation anim = animations.get(currentAnim);
        if (anim != null) {
          anim.update(delta);
        }
      }
    }
  }
View Full Code Here

      stateManager.render(g);
      return;
    }
    float xpos = x, ypos = y;
    if (currentAnim != null) {
      Animation anim = animations.get(currentAnim);
      int w = anim.getWidth();
      int h = anim.getHeight();
      int whalf = w / 2;
      int hhalf = h / 2;
      if (centered) {
        xpos = x - (whalf * scale);
        ypos = y - (hhalf * scale);
      }
      if (angle != 0) {
        g.rotate(x, y, angle);
      }
      anim.draw(xpos, ypos, w * scale, h * scale, color);
      if (angle != 0)
        g.resetTransform();
    } else if (currentImage != null) {
      currentImage.setAlpha(color.a);
      int w = currentImage.getWidth() / 2;
View Full Code Here

    this.height = sheet.getSprite(0, 0).getHeight();
  }

  public void addAnimation(String animName, boolean loop, int row,
      int... frames) {
    Animation anim = new Animation(false);
    anim.setLooping(loop);
    for (int frame : frames) {
      anim.addFrame(sheet.getSprite(frame, row), duration);
    }
    addAnimation(animName, anim);
  }
View Full Code Here

    addAnimation(animName, anim);
  }

  public Animation addAnimation(SpriteSheet sheet, String animName,
      boolean loop, int row, int... frames) {
    Animation anim = new Animation(false);
    anim.setLooping(loop);
    for (int frame : frames) {
      anim.addFrame(sheet.getSprite(frame, row), duration);
    }
    addAnimation(animName, anim);
    return anim;
  }
View Full Code Here

   * vertically.
   */
  public void addFlippedAnimation(String animName, boolean loop,
      boolean fliphorizontal, boolean flipvertical, int row,
      int... frames) {
    Animation anim = new Animation(false);
    anim.setLooping(loop);
    for (int frame : frames) {
      anim.addFrame(
          sheet.getSprite(frame, row).getFlippedCopy(fliphorizontal,
              flipvertical), duration);
    }
    addAnimation(animName, anim);
  }
View Full Code Here

  public void setAnim(String animName) {
    if (!animations.containsKey(animName)) {
      throw new IllegalArgumentException("No animation for " + animName);
    }
    currentAnim = animName;
    Animation currentAnimation = animations.get(currentAnim);
    width = currentAnimation.getWidth();
    height = currentAnimation.getHeight();
  }
View Full Code Here

    }
    if (element.hasAttribute("loop")) {
      loop = parseBooleanAttribute(element, "loop");
    }

    Animation anim = buildAnimationFromFrames(sheet, row, frames,
        frameDuration, flipHorizontal, flipVertical);
    anim.setLooping(loop);
    Log.debug(formatLoadMsg("animation", key, "spritesheet", imgName));
    ResourceManager.addAnimation(key, anim);
  }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.Animation$Frame

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.