Advertisement

07.12.2008 at 04:31PM PDT, ID: 23560156
[x]
Attachment Details

Connect button from title screen to game.

Asked by jvilla1983 in Graphics & Game Programming, Miscellaneous Games, Java Programming Language

Tags: ,

Hi,

I'm writing a game right now using Slick, Java and SUI. I'm having a few issues namely connecting my button on my title screen to the game itself. I'm also wondering how I would dispose of the current  screen and then start my game which is in the Game class.

Thanks,Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
package com.abc.ZeldaClone1;
 
import org.newdawn.slick.*;
import org.newdawn.slick.gui.*;
import org.newdawn.slick.geom.*;
import org.newdawn.slick.fills.*;
import mdes.slick.sui.*;
import mdes.slick.sui.event.ActionEvent;
import mdes.slick.sui.event.ActionListener;
import mdes.slick.sui.event.*;
import mdes.slick.sui.layout.*;
import mdes.slick.sui.event.MouseAdapter;
import mdes.slick.sui.event.MouseEvent;
 
 
public class TitleScreen extends BasicGame{
	Image backgroundImage = null;
	private Display display = null;
	private boolean displayPicture = true;
	
	public TitleScreen(){
		super("");
	}
	
	public void setImage(Image background){
		backgroundImage = background;
	}
	
	public Image getImage(){
		return null;
	}
 
	@Override
	public void init(final GameContainer container) throws SlickException {
		// TODO Auto-generated method stub
		//not implemented yet.. 
		backgroundImage = new Image("res/Title.jpg");
		
		container.getGraphics().drawImage(backgroundImage, 0, 0);
		display = new Display(container);
		
		Container contents = new Container();
		contents.setSize(300,150);
		contents.setLocation(250,375);
		contents.setOpaque(true);
		contents.setBackground(Color.black);
		
		RowLayout layout = new RowLayout(true,RowLayout.LEFT,RowLayout.CENTER);
		contents.setLayout(layout);
		
		
		Button btn = new Button("Press to Start Demo..");
		
		btn.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent event){
				display.removeAll();
			}
		});
		
		btn.pack();
		contents.add(btn);
		
		//add a label to the contents..
		Label label = new Label("Dungeon Crawler");
		label.setForeground(Color.white);
		label.pack(); //pack the label with current text
		label.setHeight(btn.getHeight());
		contents.add(label);
		
		display.add(contents);
		
		
	}
 
	@Override
	public void update(GameContainer container, int delta) throws SlickException {
		// TODO Auto-generated method stub
		display.update(container,delta);
        if (container.getInput().isKeyPressed(Input.KEY_ESCAPE))
            container.exit();
 
	}
 
	@Override
	public void render(GameContainer container, Graphics g) throws SlickException {
		// TODO Auto-generated method stub
		
		if(displayPicture == false){
		g.clear();
		}else{
			g.drawImage(backgroundImage, 0, 0);
		}
		display.render(container,g);
	}
}
[+][-]07.12.2008 at 04:41PM PDT, ID: 21990742

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.12.2008 at 04:43PM PDT, ID: 21990747

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 12:36AM PDT, ID: 21991604

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 05:05AM PDT, ID: 21992202

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 05:08AM PDT, ID: 21992225

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 01:08AM PDT, ID: 22267060

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 09:57AM PDT, ID: 22271741

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Graphics & Game Programming, Miscellaneous Games, Java Programming Language
Tags: Slick, Java, SUI, MISE 7.0
Sign Up Now!
Solution Provided By: sciuriware
Participating Experts: 2
Solution Grade: B
 
 
[+][-]08.20.2008 at 10:26AM PDT, ID: 22271974

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628