Java 2D Platformer Tutorial #4 - Creating the Menu State

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Really, only 2 likes, 3 comments and 67 views??? This video needs WAAAY more popularity. ☺☻

PP-PIG
Автор

If I load the program, it will just show a blank window. I have no errors, and I've copied down the code until the part where he checks the menu. What do you think I did wrong?

jonesyandbeast
Автор

Hey, i think something is wrong with my MenuState code. The window that pops up when i press Run, is invisible, i can see the borders of where i can minimize and close it, but in the middle is invisible so i can see through it. 
Here's the code:
import java.awt.Color;

import java.awt.Graphics;

public class menustate extends gamestate {

private String[] options = { "Start", "Help", "Quit" };
private int currentSelection = 0;

public menustate(gamestatemanager gsm) {
super(gsm);

}

public void init() {

}

public void Tick() {

}

public void draw(Graphics g) {

for (int i = 0; i < options.length; i++) {
if (i == currentSelection) {
g.setColor(Color.GREEN);
} else {
g.setColor(Color.BLACK);

}

g.drawString(options[i], gamepanel.WIDTH / 2 - 75, 100 + i * 250);
}

}

public void keyPressed(int k) {

}

public void keyReleased(int k) {

}

}

sssplllattt
Автор

0:27 That is definitely how you spell extend lol

Break.
Автор

Help me, I ran my project, and It shows the window empty,
but my menu itens (strings) don´t appear on the screen,
my project have no erros on Eclipse. I already added
the MenuState on the stack. I guess I need instructions
to make the menu itens visible, on screen. My Eclipse
console, throws a exception on gsm.draw(g) of the
method paintComponent. How can I correct this?

rodrigofontes.f
Автор

Can you tell me how to add mouse hovering effect on those Menu? I did once by adding mousemotionlistener and then in mousemoved method, I had to select the area of the reactangle of those menu to create hovering effect, I think it was not the most efficient way to do so. Do you have any better idea, Patrick?

sunnychy
Автор

Instead of testing the colours and then recompiling and running it you can go into paint and do edit colours get the colour you want and then copy the RGB down straight away. That's what I do anyway but it's preference. Lol or you could probably just do it in debug mode.

togmeister
Автор

Well done bro! Sick tutorial
Just want to ask
Whats the code for if i want to put in my own back ground instead of a color?

halo
Автор

is it important to send gamestatemanager in constructor of menustate, gamestate

lobsanggyatso
Автор

When I run the program there is no menu.

iv
Автор

Please, disconsidere my comment, finally I solve my problem.

rodrigofontes.f
Автор

Menu is not drown
Idk whats wrong, maybe it depends on ide?
I use intelligi idea

excellent