Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[HELP]Java not working Intro


rairai5650
 Share

Recommended Posts

Help guys so i made this code for intro my name before main menu nothing is error and imported what i need but the problem is, it is not working

```
public class IntroState extends GameState {

private BufferedImage logo;

private int alpha;
private int ticks;

private final int FADE_IN = 60;
private final int LENGTH = 60;
private final int FADE_OUT = 60;

public IntroState(GameStateManager gsm) {
super(gsm);
}

public void init() {
ticks = 0;
try {
logo = ImageIO.read(getClass().getResourceAsStream("/Logo/logo.gif"));
}
catch(Exception e) {
e.printStackTrace();
}
}

public void update() {
handleInput();
ticks++;
if(ticks < FADE_IN) {
alpha = (int) (255 - 255 * (1.0 * ticks / FADE_IN));
if(alpha < 0) alpha = 0;
}
if(ticks > FADE_IN + LENGTH) {
alpha = (int) (255 * (1.0 * ticks - FADE_IN - LENGTH) / FADE_OUT);
if(alpha > 255) alpha = 255;
}
if(ticks > FADE_IN + LENGTH + FADE_OUT) {
gsm.setState(GameStateManager.MENUSTATE);
}
}

public void draw(Graphics2D g) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, GamePanel.WIDTH, GamePanel.HEIGHT2);
g.drawImage(logo, 0, 0, GamePanel.WIDTH, GamePanel.HEIGHT2, null);
g.setColor(new Color(0, 0, 0, alpha));
g.fillRect(0, 0, GamePanel.WIDTH, GamePanel.HEIGHT2);
}

public void handleInput() {
if(Keys.isPressed(Keys.ENTER)) {
gsm.setState(GameStateManager.MENUSTATE);
}
}

}

```
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...