I am beginner in libgdx . When trying to make a game I get this error in Android Studio :
Error:(39, 16) Gradle: error: no suitable constructor found for Stage(Viewport,SpriteBatch) constructor Stage.Stage() is not applicable (actual and formal argument lists differ in length) constructor Stage.Stage(StageStyle) is not applicable (actual and formal argument lists differ in length)
-
public class Hud {
| public Stage stage;
| private Viewport viewport;
|
| private Integer worldTimer;
| private float timeCount;
| private Integer score;
|
| Label countdownLabel;
| Label scoreLabel;
| Label timeLabel;
| Label levelLabel;
| Label worldLabel;
| Label snakeLabel;
|
| public Hud(SpriteBatch sb) {
| | worldTimer = 300;
| | timeCount = 0;
| | score = 0;
| |
| | viewport = new FitViewport(Snake.V_WIDTH, Snake.V_HEIGHT, new OrthographicCamera());
| | stage = new Stage(viewport,sb);
| }
}
Here is the error:
stage = new Stage(viewport,sb);
I searched the internet some solution but I have not found anything. I'm a little lost. Excuse me for my bad english :) I hope you can help me . I will be grateful.
You have the wrong Stage class imported, it should be:
com.badlogic.gdx.scenes.scene2d.Stage
But you probably have this or some other package:
javafx.stage.Stage