2014-02-24 2 views
2

내 코드를 사용하여 단계를 시작한 후에 나타나는 코드에 문제가 있습니다. 일괄 처리로 3 가지를 그려야하며 스테이지에서 2 개의 버튼이 그려지는 무대가 있습니다. 내 "스프라이트"중 2 개만 그려지고 있습니다. A는이 텍스트 그려되지 않습니다 "일부 텍스트", 그리고 내가 그것을 주석 경우, 미친 간다, 제목 스프라이트 중 하나를 그려되지 않습니다되어Libgdx : 스테이지가 엉망진창입니다

public void render(float delta) { 
    Gdx.gl.glClearColor(0.95F, 0.95F, 0.95F, 0.95F); 
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); 

    deltaTime = Gdx.graphics.getDeltaTime(); 

    camera.update(); 
    generalUpdate(touch, camera, deltaTime, pointer); 
    bounce(deltaTime); 

    stage.setCamera(camera); 
    batch.setProjectionMatrix(camera.combined); 

    batch.begin(); 
     batch.draw(Assets.spr_bg, 0, 0); 
     batch.draw(Assets.spr_title, 540-Assets.spr_title.getWidth()/2, titleY-Assets.spr_title.getHeight()/2); 
     Assets.font_small.draw(batch, "some text", 540-Assets.font_small.getBounds("(c)2014 HateStone Games").width/2, 1920-64-Assets.font_small.getBounds("(c) HateStone Games").height/2); 
     stage.draw(); 
    batch.end(); 
} 

하고, 다음은 코드입니다 회색 상자가 임의의 간격으로 나타납니다.

또한 "stage.draw();" 배치 외부에 그려지지 않습니다.

+0

'stage.draw()'를'batch.begin() - batch.end()'블록 밖으로 확실히 옮겨야합니다. 두 그림의'SpriteBatch'는 verry를 함께 잘 작동하지 않습니다 ... 또한 render 메소드에'delta' 매개 변수를 가지고 있기 때문에'Gdx.Graphics.getDelta()'를 호출 할 필요가 없습니다. 내가 고칠 수있는 몇 가지 포인트. – Springrbua

+0

그것은 일괄 처리 후에'stage.draw()'를 움직이게했습니다 :) – Jolly

+0

그리고 질문을 마지막으로 읽은 후에 대답을 삭제했습니다. xD – Springrbua

답변

5

Stage에는 모든 것을 그려주는 SpriteBatch이 있습니다. 따라서 begin()SpriteBatch이고 다른 하나는 SpriteBatch입니다. 따라서 batch.end()으로 전화하기 전에 stage.draw()으로 전화하십시오. 이렇게하면 문제가 해결됩니다.