2016-05-16 43 views
1

我想按一個鍵時畫一個紋理。我使用的是isKeyJustPressed()方法,因此紋理出現並消散非常快。我怎樣才能減慢它的速度,讓我看到它出現?Libgdx鍵輸入太快紋理

回答

2

你在畫這樣的紋理嗎?

public void render() { 
    ... 
    batch.begin(); 
    ... 
    if(isKeyJustPressed...) { 
     texture.draw()... 
    } 
    ... 
    batch.end(); 
    ... 
} 

如果是這樣,你的紋理將只繪製一幀。

如果是這樣的問題:

float timeRemaining = 0f; // in seconds 
public void render() { 
    ... 
    batch.begin(); 
    ... 
    if(isKeyJustPressed...) { 
     timeRemaining = 5; // will show the texture for 5 seconds 
    } 
    if (timeRemaining>0) { 
     timeRemaining -= Gdx.graphics.getDeltaTime(); 
     texture.draw()... 
    } 
    ... 
    batch.end(); 
    ... 
} 

此外,我會強烈建議你去通過這個教程跳進製作遊戲之前。
https://docs.oracle.com/javase/tutorial/

+0

謝謝。事實上,在我做好準備之前,我開始做遊戲。我會花時間學習! – Ryncops

+0

@Ryncops當我開始製作遊戲時,我就像你一樣跳入編碼。如果你這樣做沒關係。而且如果你決定學習。學習時不要失去你的野心。 – ossobuko