Multithreaded Pacman: only last animated panel added to JFrame is displaye
843806Apr 16 2009 — edited Apr 16 2009Hello,
I am making a multithreaded pacman game. Pacman and each of the ghosts run in a separate thread.
However, only the last item (ie. pacman or one of the ghosts) added to the JFrame is displaying in the maze. (pacman and each of the ghosts are subclasses of JPanel). For example, if I do:
add(pacman);
add(orangeGhost);
add(redGhost);
only the red ghost animation will appear on the maze(which is also a subclass of JPanel).
I have tried adding the ghosts to pacman and then adding pacman i.e. pacman.add(redGhost); add(pacman); but this still doesn't work - only pacman is showing in the maze.
Each thread runs fine on its own, but only the last one added is displaying.
Any help is much appreciated.