LIBGDX: Multi-Touch
忽然想起用libgdx有段時間了,但似乎沒看到其是否支持‘矚目’的多點觸屏,于是乘著空的時候,又翻了翻libgdx的API文檔來,發現libgdx一直支持多點觸屏的,只是封裝的比較淺,加上api文檔中就一句話,所以具體實現還需要自己來琢磨。
今天沒G7可用(實際一直沒G7可用,長期被LP霸占,只有晚上偶爾可以試試,可憐啊。。。)看著API文檔,猜測下面API的意思,然后寫段測試,興奮地用同事的G8做了測試,果然這樣,甚是歡喜啊。。。
touchDragged
boolean touchDragged(int x,
int y,
int pointer)
Called when a finger or the mouse was dragged.
Parameters:
x - The x coordinate
y - The y coordinate
pointer - the pointer for the event.
Returns:
whether the input was processed這里是測試代碼:
public boolean touchDragged(int x, int y, int pointer) {
// TODO Auto-generated method stub
if(p0 == true && p1 == true) {
if(pointer == 0) {
if(x0 < x1) {
if(x < x0 && y > y0)
this.moon.zoomOut();
else if(x > x0 && y < y0)
this.moon.zoomIn();
}
else if(x0 > x1) {
if(x < x0 && y > y0)
this.moon.zoomIn();
else if(x > x0 && y < y0)
this.moon.zoomOut();
}
}
else if(pointer == 1) {
if(x0 < x1) {
if(x < x1 && y > y1)
this.moon.zoomIn();
else if(x > x1 && y < y1)
this.moon.zoomOut();
}
else if(x0 > x1) {
if(x < x1 && y > y1)
this.moon.zoomOut();
else if(x > x1 && y < y1)
this.moon.zoomIn();
}
}
}
return super.touchDragged(x, y, pointer);
}posted on 2011-06-17 17:59 codejie 閱讀(2162) 評論(6) 編輯 收藏 引用 所屬分類: 輪子精神 、G7



