FadeOutTransition in Slick2D render problem

19 views Asked by At

I have a graphic problem when i try to leave a GameState in my game with a FadeOutTransition.

public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta) 
throws SlickException {     
    if (gameContainer.getInput().isKeyPressed(Input.KEY_ENTER)) {
        stateBasedGame.enterState(1, new FadeOutTransition(), new FadeInTransition());
    }
}

Where "1" is the ID of the next GameState where i want to enter. the aniamtion isn't fluid but first fade out only a part of my screen then the other fadeout the other part. i figured out that the problem is the position of my character and maybe the translation of the graphics with a camera.

public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics g) 
throws SlickException {
    g.translate(-camera.getX(), -camera.getY());

    //stuff to render

    g.translate(camera.getX(), camera.getY());
}

There is my camera class update method that allow to set the x and y of the camera to follow the main character. Object is the player, scaleFactor is the scale that i pass on the g.scale(... , ...) method, setup.WIDTH is the width of the Screen, setup.HEIGHT is the height of the Screen.

public void update() {
    x = object.getX()*scaleFactor - Setup.WIDTH/2f;
    y = object.getY()*scaleFactor - Setup.HEIGHT/2f;
}
0

There are 0 answers