title: Programming a game using the Javafx class from a tutorial and have come across an undefined class error
body: <pre><code>else if(left || right) {
      if(currentAction != WALKING) {
          currentAction = WALKING;
          animation.setFrames(sprites.get(WALKING));
          animation.setDelay(40);
          width = 30;
  </code></pre>
  
  <p>Here is the code I am having issues with. namely the <code>animation.setFrames</code> and <code>setDelay</code> the <code>setFrames</code> uses a <code>BufferedImage</code> array and the <code>setDelay</code> is a <code>long</code> variable. The two errors that come up are</p>
  
  <pre><code>The method setFrames(BufferedImage[]) is undefined for the type Animation
  </code></pre>
  
  <p>and </p>
  
  <pre><code>The method setDelay(Duration) in the type Animation is not applicable for the arguments (int)
  </code></pre>
  
   
  
  <pre><code>public void setFrames(BufferedImage[] frames) {
          this.frames = frames;
          currentFrame = 0;
          startTime = System.nanoTime();
          playedOnce = false;
  </code></pre>
  
  <p>this is the code for the <code>setFrames</code> and the code of <code>delay</code>'s setter is just</p>
  
  <pre><code>public void setDelay(long d) {
      delay = d;
  }
  </code></pre>
  
  <p>Any assistance is welcome.<br>
  There were none of these errors in the tutorial<br>
  EDIT: I have created a new <code>Animation</code> class in the constructor but it did not solve it. Added Animation class</p>
  
  <pre><code>  package Entity;
  
      import java.awt.image.BufferedImage;
  
      public class Animation {
          private BufferedImage[] frames;
          private int currentFrame;
  
          private long startTime;
          private long delay;
  
          private boolean playedOnce; played; e.g. an attack so it does not
  
  
          public void Animation() {
              playedOnce = false;
          }
  
          public void setFrames(BufferedImage[] frames) {
              this.frames = frames;
              currentFrame = 0;
              startTime = System.nanoTime();
              playedOnce = false;
          }
  
          public void setDelay(long d) {
              delay = d;
          }
  
          public void setFrame(int i) {
              currentFrame = i;
          }
  
          public void update() {
              if (delay == -1)
                  return;
              long elapsed = (System.nanoTime() - startTime) / 1000000;
              if (elapsed &gt; delay) {
                  currentFrame++;
                  playedOnce = true;
  
              }
  
          }
  
          public int getFrame() {
              return currentFrame;
          }
  
          public BufferedImage getImage() {
              return frames[currentFrame];
          }
  
          public boolean hasPlayedOnce() {
              return playedOnce;
          }
      }
  </code></pre>