The easiest way is to use one at a time. I setup my splash panel like this.
class MSplashPanel extends JPanel
{
Image splashImage;
public MSplashPanel()
{
setPreferredSize(new Dimension(800,600));
splashImage = MData.loadImage("./images/splash1.jpg");
}
public void paint(Graphics g)
{
int iw = splashImage.getWidth(null);
int ih = splashImage.getHeight(null);
// center the image
g.drawImage(splashImage,(getWidth()-iw)/2,(getHeight()-ih)/2,null);
}
}
I then setup my main like this (This started as Tmpl3).
public int splashTicks = 80;
public M3d()
{
super("M3d");
m3dMain = this;
// get the container for the frame
Container c = getContentPane();
c.setLayout(new BorderLayout());
// create our panel
panelM = new M3dPanel();
panelM.parent = this;
panelSplash = new MSplashPanel();
// add out panel to the container
c.add(panelSplash, BorderLayout.CENTER);
// create the thread for the splash and menu panels
Thread t = new Thread(this);
t.start();
// set frame properties, pack and show
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String[] args)
{
// create the jframe
M3d app = new M3d();
}
public void run()
{
while (running)
{
if (mode==MODE_SPLASH)
{
splashTicks--;
if (splashTicks<0)
{
Container c = getContentPane();
c.remove(panelSplash);
c.add(panelM, BorderLayout.CENTER);
pack();
mode=MODE_PLAY;
return; // quit the thread
}
}
try
{
Thread.sleep(25);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
Notice the run method removes the splash panel after the ticks have expired and adds the 3d panel.
I'll have another example of removing a 3d element shortly.
Wood
--
http://www.memorize-it.com
From: bake...@chapman.edu
Sent: Monday, May 15, 2006 2:17 PM
To: GameD...@googlegroups.com
Subject: [GameDev370] Topics for help tonight:
Hi Wood,
Thanks for rearranging your life for us. Some topics I want to ask you
about for tonight, just to give you a heads up:
-Is there a way I can switch from 2D to 3D? I'm trying to think how to do
the splash screen.
-Moving models in 3D
-Can I unload models?
Thanks,
Mike
> Wouldn't you know that my phone would ring within 15 seconds of sending
> the lunch help notice. I have to help load a container for Africa. We have
> a container of stuff going on our next AIDs relief trip to Namibia.
>
> I've cancelled my evening plans so I can come help on campus. I'll leave
> work around 5pm and arrive at the library between 5:30 and 6. If there are
> any problems with room availability I will be in the beckman cafe. I will
> stay as long as needed. I hope this works with everyone's schedule.
>
> Wood
>
>
>
> >