2016-01-13 98 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

感謝你這麼多!我終於可以繼續我的遊戲了:) –

相關問題