2017-02-10 66 views
0

我正在開發一個遊戲,在渲染功能我有渲染: (廣場擴展Sprite)Libgdx對象只在點擊

@Override 
    public void render(float delta) { 
     Gdx.gl.glClearColor(0, 0, 0, 0); 
     Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 
     batch.begin(); 
     backgroundSprite.draw(batch); 

     endTime = System.currentTimeMillis(); 
     if((endTime-startTime) > 1000) { 
      squareList.add(squarePositionFactory.getSquare()); 
      for(Square square : squareList) { 
       square.setSize(80, 80); 
       square.draw(batch); 
       square.updatePosition(square.posX, square.posY + 100); 
       startTime = System.currentTimeMillis(); 
       Gdx.app.log("[Playing time]", square.toString()); 
      } 
     } 
     batch.end(); 

     stage.act(Gdx.graphics.getDeltaTime()); 
     stage.draw(); 
    } 

問題是,當我點擊repeatdly渲染方法僅適用在屏幕上顯示圖像閃爍。我怎樣才能解決這個問題?謝謝!

回答

0

你還沒有將演員加入舞臺。

stage.addActor("your actor"); 
    stage.draw();