Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't comment so I will just say it here and edit when you answer, What is your code like so far? what have you tried ? there are quite a few ways to achieve what you want, but your question is sort of lacking detail.</p> <p>edit: You arn't showing a field named grow, and it isn't a good idea to have a field/variable by the name of grow and have a method named grow.</p> <p>One thing you can do according to yours would be something like.</p> <pre><code>public class Sprite extends JFrame implements ActionListener { public boolean Grown; public Board board; // never set in your example, // nor do i have any idea what it is for public Timer timer; public BufferedImage UngrownImage; // Initialize these images yourself public BufferedImage GrownImage; public sprite() { Grown = false; timer = new Timer(1000, this); timer.start(); } public void actionPerformed(ActionEvent e) { Grown = true; board.repaint(); // you may want to call super.repaint() too // but again I do not know what board is. } // unless your "Board" is taking care of it, here you can paint the images public void paint(Graphics g) { super.paint(g); int imgX = 0, imgY = 0; if(Grown &amp;&amp; GrownImage != null) g.drawImage(GrownImage, imgX, imgY, null); else if(UngrownImage != null) g.drawImage(UngrownImage, imgX, imgY, null); else System.out.println("error: No images loaded"); } } </code></pre> <p>If there is anything you do not understand let me know, I will gladly summarize it to you, I assumed that all this is stuff you have worked with, judging off of what you are trying to do.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload