2016-01-13 66 views
1

我是libgdx的初学者。当试图做一个游戏,我得到这个错误Android Studio中:无法解析构造函数'Stage(com.badlogic.gdx.utils.viewport.Viewport,com.badlogic.gdx.graphics.g2d.SpriteBatch)'

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);  
| } 
} 

以下是错误:

stage = new Stage(viewport,sb); 

我在网上搜索了一些解决方案,但我有找不到任何东西。我有点迷路。 对不起我英文不好:) 我希望你能帮助我。我会很感激。

回答

0

您已经导入了错误的Stage类,它应该是:

com.badlogic.gdx.scenes.scene2d.Stage 

但你可能有这样或其它的什么包:

javafx.stage.Stage 
+0

感谢你这么多!我终于可以继续我的游戏了:) –

相关问题