title: Getting a strange error while trying to draw an image in java?
body: <p>I am trying to move a function from the main class to a sub-class in a small game I'm making. I have copied and pasted the function from the main class into a sub-class and for some reason I am getting this error: </p>
  
  <pre><code>no suitable method found for drawImage(java.awt.Image,int,int,pony)
  method java.awt.Graphics2D.drawImage(java.awt.BufferedImage, java.awt.BufferedImageOp, int, int) is not applicable; (actual argument java.awt.Image cannot be converted to java.awt.BufferedImage by method invocation conversion);
  </code></pre>
  
  <p>This is the function:</p>
  
  <pre><code>public void explode(Graphics g)
  {
      Graphics2D g2d = (Graphics2D) g;
  
      int i=0;
      float angle = 0.03f;
      float PI = 3.14159f;
      int x2,y2;
      int r=40;
  
      while(r&lt;200)
      {
          while (angle &lt; 2 * PI)
          {
              x2 = (int)this.x + (int) (Math.cos(angle)*r);
              y2 = (int)this.y + (int) (Math.sin(angle)*r);
  
              g2d.drawImage(sparkles[i].getImage(), x2, y2,this);
  
              angle+=0.1;
              i+=1;
          }
          i=0;
          angle=0.03f;
          r+=5;
      }
  
  }
  </code></pre>
  
  <p>Here is the function call in the main class:</p>
  
  <pre><code>public void paintComponent(Graphics g)
  {
      super.paintComponent(g);
      Graphics2D g2d = (Graphics2D) g;
  
      for(int i=0;i&lt;curPonies;i++)
      {
         if(ponies[i].colliding())
         {
            ponies[i].explode(g);
         }
      }
  }
  </code></pre>
  
  <p>If I move the explode function into the main class it works perfectly, but if I try to call it from another class I get the error above. If anyone can tell me why this happens, I would very much appreciate the help.</p>
  
  <p>Thank you very much!</p>