0
我試圖在由libgdx庫構建的java應用程序上加載兩個圖像。然而,我加載了背景圖像,如果我沒有將圖像的位置設置爲(0,0),我無法將其他圖像加載到屏幕上。例如, ; 我設置圖像的位置爲0,0,沒有問題。但是,當我將圖像的位置設置爲20,0時,無法看到。使用libgdx加載圖像
batch.draw(Assets.coinRegion, position.x, position.y, 1, 1)
我想用上面的代碼畫出圖像。
謝謝。
編輯:
obstacle = loadTexture("data/obstacle.png");
obstacleRegion = new TextureRegion(obstacle, 0, 0, 64, 64);
world.obstacle.position.x += 0.001;
batch.draw(Assets.obstacleRegion,
world.obstacle.position.x, world.obstacle.position.y, 1, 1);
在我的狀態下,我有兩個單獨的圖像,其中一個是64x64,另一個是32x32。我創建了兩個TextureRegion並嘗試繪製它們,就像我在我的問題中寫的一樣。在0,0的位置上,他們很好,否則不會。編輯:在我的程序中,我試圖獲取像region = new TextureRegion(texture,0,0,64,64)的圖像。 –
你能提供你所有的代碼嗎? – Aleksandrs
'obstacle = loadTexture(「data/obstacle.png」); \t \t obstacleRegion = new TextureRegion(obstacle,0,0,64,64); world.obstacle.position.x + = 0.001; \t \t batch.draw(Assets.obstacleRegion,world.obstacle.position.x, \t \t \t \t world.obstacle.position.y,1,1);'如果我設置world.obstacle.position.x和position.y爲0,0,否則不行。這段代碼是否正確。由於這是評論區,我無法發佈更多。 –