简体   繁体   中英

Java - Libgdx : Issue with the condition Else

I'm trying to write a condition but the else structure always show me an error:

Skin skin;
        skin = new Skin(Gdx.files.internal("default/skin/uiskin.json"));
        réponse = new TextField("", skin);
        réponse.setPosition(stage.getWidth() / 2 - 445, stage.getHeight() / 1 - 1600);
        réponse.setSize(900, 120);
        stage.addActor(réponse);

        if (réponse.getText().equals("riviere")){
            game.setScreen(new Stage1(game));
            music.stop();
        }
        else (!réponse.equals("riviere")){
            ecrireLeTexte = true;
        }

Code explanation: I want to make a condtion as if the user enter the good word (riviere) it will lead it to the next screen if not it will verify the boolean of ecrireLeTexte which is drawing the text "not the good word, retry"

You're missing the 'if' keyword in front of the 'else' keyword:

else if(!réponse.equals("riviere")){

That indicates that if the first condition was not passed, it delegates to the second one. There can be multiple 'else if's:

if(false){
    // Nope...
} else if(false){
    // Nope...
} else if(true){
    // Success!
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM