0
退出後,屏幕無法第二次啓動這是menuscreen類,當被調用時將使用作爲參數傳遞的spritebatch繪製menuscreen。問題在於繪圖命令無法第二次執行(即,在我們重新啓動應用程序之後),而所有其他功能都可以正常工作(如果單擊放置在屏幕上的位置,您仍然可以使用我們放置在屏幕上的按鈕)安卓(libgdx)
public class MenuScreen extends Screen
{
Texture Background,Playgame,Credits;
Vector2 PlaygamePos,CreditsPos;
Rectangle PlaygameRect,CreditsRect,touchRect;
public MenuScreen()
{
Background = GameEngine.LoadTexture("Menu/bg.png");
GameEngine.BackgroundTexture = Background;
Playgame = GameEngine.LoadTexture("Menu/newgame.png");
Credits = GameEngine.LoadTexture("Menu/credits.png");
PlaygamePos = new Vector2(500,300);
CreditsPos = new Vector2(500,200);
PlaygameRect = new Rectangle(PlaygamePos.x,PlaygamePos.y,Playgame.getWidth(),Playgame.getHeight());
CreditsRect = new Rectangle(CreditsPos.x,CreditsPos.y,Credits.getWidth(),Credits.getHeight());
}
@Override
public void Update(OrthographicCamera camera)
{
if(GameEngine.isBackButton == true)
{
GameEngine.isBackButton = false;
Gdx.app.exit();
}
if(GameEngine.isTouched() == true)
{
Vector3 touchPos = new Vector3();
touchPos = GameEngine.TouchPos(camera);
touchRect = new Rectangle(touchPos.x,touchPos.y,10,10);
if(touchRect.overlaps(PlaygameRect))
{
SelectScreen = ScreenSelect.GamePlay;
}
else if(touchRect.overlaps(CreditsRect))
{
}
}
}
@Override
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.draw(Credits,CreditsPos.x,CreditsPos.y);
spriteBatch.draw(Playgame,PlaygamePos.x,PlaygamePos.y);
}
@Override
public void Resume() {
// TODO Auto-generated method stub
}
@Override
public void Pause() {
// TODO Auto-generated method stub
}
@Override
public void Dispose()
{
}
}
即使我們試圖處置紋理和SpriteBatches沒有工作!