Pac-Man in NetBeans- a Timer and jLabel/jPannel problem
While looking for a solution for my problem i discovered this site so I registered to see if anyone could help me out with this one...
This is the description, I can post pieces of code or the entire program if required.
So basically I am doing a Pac-Man game, using NetBeans.
I use jLabels/jPannels to display the user controlled icon and obstacles, plus a timer and key event listener to move pac-man around.
Example if the "down key" is pressed every 100ms the loop sets the icon's position to (x,y+1).
I've double checked everything and pac-man travels correctly and reacts to the obstacles and borders properly.
I've also already done a very basic method for a "ghost" which randomly travels around.
The problem is as follows :
Every time I change the text of a label or hide it, the labels which i move around
(the jlabels that contain the pac-man icon and the ghost icon or jpannels)
get reset to their starting position - (for example 0,0).
Even if I put a setLocation right afterwards it just ignores it.
Since this is my first time working with a Timer I've figured out there might be something I don't know.
Anyone I've asked so far didn't know the answer, since I'm sure people here have more experience
I believe someone will be able to provide me with a solution.
Thank you very much.