Drawing image Slick2d not working

The strangest thing is happening, and I can’t understand it. I am doing a StateBasedGame, and in one of the BasicGameStates I am trying to draw an image. However, he looks white. The code:

@Override
    public void render(GameContainer arg0, StateBasedGame arg1,
            Graphics g) throws SlickException {
        // TODO Auto-generated method stub
        g.setBackground(Color.blue);
        Image image = new Image("res/Sniper Scope (Border).png");
        g.drawImage(image, 230,100);
    }

It seems that you find the image (it does not fall), but all that arises is:

Any help would be greatly appreciated.

+3
source share
1 answer

Move the initialization / declaration of the image to the init method. If you want to call the image in the visualization area, you need the image to be global, and then initialize it in the Init method.

: , slick (x, y)! g.drawImage(). : img = ( "res/Image.png" );

: img.draw(0, 0);

+1

All Articles