2014-06-25 67 views
0

我正在使用畫布和視圖繪製我的位圖到屏幕。當我打開屏幕時,圖像的位置出現了一系列滯後現象(就好像我正在看計算機一樣,慢慢想想要放置點的位置)。Java - 繪製位圖是laggy

首先是這樣的:

enter image description here

然後:

enter image description here

最後:

enter image description here

我明白我t對我給出的描述很難,但如果有人有任何想法,他們可以請告訴我!

編輯:

public class LoseScreen extends View { 

    @Override protected void onDraw(Canvas canvas) { 

    paint.setColor(Color.GREEN); 

    canvas.drawBitmap(box, null, menuBox, null); 

    menuBox.set(screenWidth/2 - menuWidth/2, screenHeight/2 - menuHeight/2, menuBox.left + menuWidth, menuBox.top + menuHeight); 
    tryagainBounds.set(screenWidth/2 - tryagainWidth/2, menuHeight/2, tryagainBounds.left + tryagainWidth, tryagainBounds.top + tryagainHeight); 


    canvas.drawText(" Score:", 100 * density, menuBox.top + 150 * density, finalScorePaint); 
    canvas.drawText(finalScoreString, 225 * density, menuBox.top + 150 * density, finalScorePaint); 

    canvas.drawText("Highscore:", 100 * density, menuBox.top + 200 * density, finalScorePaint); 
    canvas.drawText(HighScore.toString(), 225 * density, menuBox.top + 200 * density, finalScorePaint); 

    canvas.drawBitmap(tryagain, null, tryagainBounds, null); 
+2

請在畫布上繪製位圖的位置添加代碼,否則無法提供幫助。 – tknell

+0

你正在加載主UI線程上的位圖嗎? –

+0

我添加了代碼,我不知道我是否在主UI線程上加載它,不知道這意味着什麼。我有多個加載位圖的屏幕,如果這就是你的意思? – Divergent

回答

0

很難知道你的問題是什麼,沒有看到任何代碼。 但一個想法可以確保繪製圖像在屏幕上,當您使用雙緩衝(http://docs.oracle.com/javase/tutorial/extra/fullscreen/doublebuf.html

的這是什麼一樣基本描述:繪製圖像關閉屏幕,而它正在「建造」,然後移動它完成時的視圖。這不會加速繪圖過程。