Lets say I want a menu directing me to the game, high scores, and options. I was thinking that I could do this by having 3 JPanels open and bringing the appropriate one to the front when I need it (can I do that?) or is there another way that would give better results?
My issue with that thought is that going back to the main, I would need to restart the game. However I think I can fix that by resetting current variables to default and then just repainting the game as necessary. But to do this, I need to know how to destroy classes as such (JPanels, monster class etc) or is setting them to 'null' essentially achieving the same thing? Then I just re-instantiate them
-----------------------------------
My other 2 questions are:
If I assign something like this:
public void foo() {
Block[] tiles = new Block[];
tiles[1] = new blockpiece(); // How do I reference new block() //blockpiece extends block
if (tiles[1] == ???) { // <-- in here, since it doesn't have an instance name?
... // I want to check if tiles[1] is a blockpiece
}
}
---------------------------------------------
and Lastly:
How do I call a variable/method in the Main class of my application. (Ignore syntax).
Class Main {
public int x; // How do I call this from another class?
public static void main(... {
}
}
Sorry if this was too much, I don't like to make a lot of threads.
This post has been edited by Mylo: 12 October 2011 - 05:02 AM

New Topic/Question
Reply



MultiQuote








|