not showing the background image [message #1730024] |
Thu, 21 April 2016 02:48 |
anthony rodelo Messages: 1 Registered: April 2016 |
Junior Member |
|
|
HI I'm working a project before school starts in june to reduce my tuition by 5k so I decided to do this tutorial on youtube as my project but I copied every thing that the guy said to write but on his page he is not getting the same error I do not no why I am getting this error i tried to run in debug mode to show the background picture but I think this error is stopping it can you help please its line 30 setVector package GameState;
import TileMap.Background;
import java.awt.*;
import java.awt.event.KeyEvent;
public class MenuState extends GameState {
private Background bg;
private int currentChoice = 0;
private String[] options = {
"Start",
"Help",
"Quit",
};
private Color titleColor;
private Font titleFont;
private Font font;
public MenuState(GameStateManager gsm) {
this.gsm = gsm;
try {
bg = new Background("/Backgrounds/menubg.gif", 1);
bg.setVector(-0.1, 0);
titleColor = new Color(120, 0, 0);
titleFont = new Font("Century Gothic", font.PLAIN, 28);
font = new Font("Arial", Font.PLAIN, 12);
}
catch(Exception e){
e.printStackTrace();
}
}
public void init(){}
public void update(){
bg.update();
}
public void draw(Graphics2D g){
// draw bg
bg.draw(g);
// draw title
g.setColor(titleColor);
g.setFont(titleFont);
g.drawString("Dragon Tale", 80, 70);
// draw menu options
g.setFont(font);
for(int i = 0; i < options.length; i++) {
if(i == currentChoice) {
g.setColor(Color.BLACK);
}
else{
g.setColor(Color.RED);
}
g.drawString(options[i], 145, 140 + i * 15);
}
}
private void select(){
if(currentChoice == 0) {
// start
}
if(currentChoice == 1) {
//help
}
if(currentChoice == 2){
System.exit(0);
}
}
public void keyPressed(int k){
if(k == KeyEvent.VK_ENTER) {
select();
}
if(k == KeyEvent.VK_UP) {
currentChoice--;
if(currentChoice == -1) {
currentChoice = options.length - 1;
}
}
if(k == KeyEvent.VK_DOWN) {
currentChoice++;
if(currentChoice == options.length) {
currentChoice = 0;
}
}
}
public void keyReleased(int k){}
}
|
|
|
Re: not showing the background image [message #1730119 is a reply to message #1730024] |
Thu, 21 April 2016 13:34 |
|
On 04/21/2016 06:53 AM, anthony rodelo wrote:
> HI I'm working a project before school starts in june to reduce my
> tuition by 5k so I decided to do this tutorial on youtube as my project
> but I copied every thing that the guy said to write but on his page he
> is not getting the same error I do not no why I am getting this error i
> tried to run in debug mode to show the background picture but I think
> this error is stopping it can you help please its line 30 setVector
> package GameState;
>
> [snip]
The purpose of this forum is to answer questions on the set-up and use
of the Eclipse IDE. It's not to answer beginning programming or even
general programming questions.
I would suggest a) that you step through in the debugger, b) figure out
how better to state your question and c) try a forum such as
javaranch.com or stackoverflow.com.
Best of luck.
|
|
|
Powered by
FUDForum. Page generated in 0.07939 seconds