0
A
回答
0
將onTouch偵聽器添加到當前視圖(http://developer.android.com/reference/android/view/View.OnTouchListener.html),並在onTouch方法中添加一個數組(或arraylist等)a自定義對象包含所需圖像的變量以及觸摸事件(event.getX(),event.getY())中的x/y座標。
例如
class Enemy{
public Image image;
public int x;
public int y;
public Enemy(Image i, int x, int y){
this.image=i;
this.x=x;
this.y=y;
}
}
然後ovveride所述的onDraw方法爲視圖,並添加一個環,其穿過ArrayList和繪製圖像的視圖例如
for (Enemy e : enemies) {
canvas.drawBitmap(e.image, e.x, e.y, null);
}
相關問題
- 1. 如何調用iphone上的圖像觸摸事件
- 2. UIViewController圖像觸摸事件
- 3. 如何在觸摸事件android中添加移動圖像?
- 4. 如何在用戶觸摸事件時在xml佈局上移動圖像?
- 5. 混合圖層圖像上的觸摸事件Android
- 6. 如何在iphone上觸摸事件突出顯示圖像
- 7. 如何禁用觸摸事件android
- 8. 圖像查看閃爍上的觸摸事件在調整大小時
- 9. Android - 滾動時禁用觸摸事件
- 10. 如何在觸摸事件上畫線?
- 11. 如何在iPhone上手動調用UIView的觸摸事件?
- 12. 在石英圓圖上觸摸事件?
- 13. 在sw圖上觸摸事件3
- 14. 在UIView上觸摸事件
- 15. 在UITableView上觸摸事件?
- 16. 在觸摸事件上重繪畫布上的圖像?
- 17. Xcode刪除觸摸事件圖像?
- 18. 移動圖像與觸摸事件
- 19. 在Android中禁用WebView觸摸事件
- 20. Android上的觸摸事件SDL2
- 21. Android上的JavaScript中的觸摸事件
- 22. 如何在觸摸事件中移動圖像?
- 23. 同時觸摸事件的Android
- 24. 如何在圖像觸摸上顯示小提示android
- 25. Android中的觸摸事件
- 26. Android Soundpool - 觸摸事件
- 27. Android TextView觸摸事件
- 28. Android的觸摸事件
- 29. 如何在android中停止觸摸事件所需的時間?
- 30. 如何防止在Android中刷卡時發生觸摸事件?
謝謝!但是如何在eclipse上加載圖像?我應該怎麼做才能讓圖像看起來接觸? – user1055700
將圖像放入您的可繪製文件夾並使用此代碼加載它。 canvas.drawBitmap是使其出現的方法。往上看。位圖圖像= BitmapFactory.decodeResource(getResources(),R.drawable.image); – ghostbust555