簡體   English   中英

刪除精靈Libgdx Java

[英]Removing sprite Libgdx Java

我有一個精靈,它表示為一個用於操作和提供信息的矩形,頂部具有紋理。 這是我的代碼:

int carrotScore;
    boolean onCarrot = true;
    Rectangle carrot;

    carrotScore = 0;

carrot = new Rectangle();
        carrot.height = 100;
        carrot.width = 100;
        carrot.x = 50;
        carrot.y = 50;

if(carrot.overlaps(farmer) && onCarrot!= false){
                onCarrot = false;
                carrotScore += 1;               
            }

if(carrotScore == 2){
                game.setScreen(new Level2Complete(game));
            }

if(onCarrot = true){
                game.batch.draw(carrotTexture, 50, 50, 100, 100);
            }

但是,當我運行它並且精靈重疊時,先前的圖形仍然顯示並且沒有消失,盡管它將屏幕更改為level2Complete,所以仍在計數嗎? 有什么主意為何仍在計算胡蘿卜,圖形為何不消失?

if(onCarrot = true)

應該

if(onCarrot == true)

您正在分配onCarrot = true而不是檢查它是否為true。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM