rairai5650 Posted October 31, 2014 Author Share Posted October 31, 2014 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 More sharing options...
abhi2011 Posted October 31, 2014 Share Posted October 31, 2014 Shouldn't g.setColor be called before g.DrawImage? Link to comment Share on other sites More sharing options...
rairai5650 Posted October 31, 2014 Author Share Posted October 31, 2014 not working either, i just fix it but the next problem is the intro only showing white i try abhi said but still not working Link to comment Share on other sites More sharing options...
rairai5650 Posted November 1, 2014 Author Share Posted November 1, 2014 bump^^ Link to comment Share on other sites More sharing options...
pandacoder Posted November 17, 2014 Share Posted November 17, 2014 Does it have something to do possibly with "HEIGHT2"?What's the back-end for this by the way? It looks to me like there's an abstraction layer. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now