私のこの質問は、ここにある私の前の質問にいくらか関連しています...私はでXとYの値を取得していTouchEvent.ACTION_MOVE
ます。指をゆっくり動かすと正常に動作しますが、指を速く動かすと、履歴イベントを使用したがまだ役に立たないX座標とY座標が失われます。ジャンプせずに連続したX値とY値が必要です。
サンプルコード
void printSamples(MotionEvent ev, RectangleParticleEmitter ps) {
final int historySize = ev.getHistorySize();
final int pointerCount = ev.getPointerCount();
for (int h = 0; h < historySize; h++) {
System.out.println("At time "+ ev.getHistoricalEventTime(h));
for (int p = 0; p < pointerCount; p++) {
System.out.println("****************************************");
System.out.println("Pointer Count "+pointerCount);
System.out.println("Pointer "+ev.getPointerId(p));
System.out.println("Historical X "+ev.getHistoricalX(p, h));
System.out.println("Historical Y "+ev.getHistoricalY(p, h));
System.out.println("****************************************");
ps.setCenter(ev.getHistoricalX(p), ev.getHistoricalY(p));
}
}
System.out.printf("At time %d:", ev.getEventTime());
for (int p = 0; p < pointerCount; p++) {
System.out.println("#######################################");
System.out.println("Pointer ID "+ev.getPointerId(p));
System.out.println("Pointer X "+ev.getX(p));
System.out.println("Pointer Y "+ev.getY(p));
System.out.println("#######################################");
}
}
ログ
03-15 07:41:17.570: I/System.out(2877): At time 12650702
03-15 07:41:17.570: I/System.out(2877): ****************************************
03-15 07:41:17.570: I/System.out(2877): Pointer Count 1
03-15 07:41:17.570: I/System.out(2877): Pointer 0
03-15 07:41:17.570: I/System.out(2877): Historical X 21.441616
03-15 07:41:17.570: I/System.out(2877): Historical Y 416.5561
03-15 07:41:17.570: I/System.out(2877): ****************************************
03-15 07:41:17.570: I/System.out(2877): At time 12650716:#######################################
03-15 07:41:17.570: I/System.out(2877): Pointer ID 0
03-15 07:41:17.580: I/System.out(2877): Pointer X 26.729622
03-15 07:41:17.580: I/System.out(2877): Pointer Y 412.76462
03-15 07:41:17.580: I/System.out(2877): #######################################
03-15 07:41:17.600: I/System.out(2877): At time 12650725
03-15 07:41:17.600: I/System.out(2877): ****************************************
03-15 07:41:17.610: I/System.out(2877): Pointer Count 1
03-15 07:41:17.610: I/System.out(2877): Pointer 0
03-15 07:41:17.610: I/System.out(2877): Historical X 38.56469
03-15 07:41:17.610: I/System.out(2877): Historical Y 405.6872
03-15 07:41:17.610: I/System.out(2877): ****************************************
03-15 07:41:17.610: I/System.out(2877): At time 12650745:#######################################
03-15 07:41:17.610: I/System.out(2877): Pointer ID 0
03-15 07:41:17.610: I/System.out(2877): Pointer X 55.56185
03-15 07:41:17.610: I/System.out(2877): Pointer Y 393.93365
03-15 07:41:17.610: I/System.out(2877): #######################################
03-15 07:41:17.640: I/System.out(2877): At time 12650751
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): Pointer Count 1
03-15 07:41:17.640: I/System.out(2877): Pointer 0
03-15 07:41:17.640: I/System.out(2877): Historical X 79.86151
03-15 07:41:17.640: I/System.out(2877): Historical Y 378.89417
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): At time 12650760
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): Pointer Count 1
03-15 07:41:17.640: I/System.out(2877): Pointer 0
03-15 07:41:17.640: I/System.out(2877): Historical X 111.46365
03-15 07:41:17.640: I/System.out(2877): Historical Y 359.43127
03-15 07:41:17.640: I/System.out(2877): ****************************************
03-15 07:41:17.640: I/System.out(2877): At time 12650774:#######################################
03-15 07:41:17.640: I/System.out(2877): Pointer ID 0
03-15 07:41:17.640: I/System.out(2877): Pointer X 151.1237
03-15 07:41:17.640: I/System.out(2877): Pointer Y 336.3033
03-15 07:41:17.640: I/System.out(2877): #######################################
03-15 07:41:17.670: I/System.out(2877): At time 12650786
03-15 07:41:17.670: I/System.out(2877): ****************************************
03-15 07:41:17.670: I/System.out(2877): Pointer Count 1
03-15 07:41:17.670: I/System.out(2877): Pointer 0
03-15 07:41:17.670: I/System.out(2877): Historical X 199.09349
03-15 07:41:17.670: I/System.out(2877): Historical Y 308.4992
03-15 07:41:17.670: I/System.out(2877): ****************************************
03-15 07:41:17.670: I/System.out(2877): At time 12650794:#######################################
03-15 07:41:17.670: I/System.out(2877): Pointer ID 0
03-15 07:41:17.670: I/System.out(2877): Pointer X 251.84766
03-15 07:41:17.670: I/System.out(2877): Pointer Y 279.93683
03-15 07:41:17.670: I/System.out(2877): #######################################
03-15 07:41:17.690: I/System.out(2877): At time 12650812
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): Pointer Count 1
03-15 07:41:17.690: I/System.out(2877): Pointer 0
03-15 07:41:17.690: I/System.out(2877): Historical X 309.51215
03-15 07:41:17.690: I/System.out(2877): Historical Y 248.97314
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): At time 12650818
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): Pointer Count 1
03-15 07:41:17.690: I/System.out(2877): Pointer 0
03-15 07:41:17.690: I/System.out(2877): Historical X 371.33145
03-15 07:41:17.690: I/System.out(2877): Historical Y 218.51501
03-15 07:41:17.690: I/System.out(2877): ****************************************
03-15 07:41:17.690: I/System.out(2877): At time 12650832:#######################################
03-15 07:41:17.690: I/System.out(2877): Pointer ID 0
03-15 07:41:17.690: I/System.out(2877): Pointer X 431.89175
03-15 07:41:17.690: I/System.out(2877): Pointer Y 189.06793
03-15 07:41:17.690: I/System.out(2877): #######################################
03-15 07:41:17.710: I/System.out(2877): At time 12650840
03-15 07:41:17.710: I/System.out(2877): ****************************************
03-15 07:41:17.710: I/System.out(2877): Pointer Count 1
03-15 07:41:17.710: I/System.out(2877): Pointer 0
03-15 07:41:17.710: I/System.out(2877): Historical X 492.2002
03-15 07:41:17.710: I/System.out(2877): Historical Y 159.2417
03-15 07:41:17.710: I/System.out(2877): ****************************************
03-15 07:41:17.710: I/System.out(2877): At time 12650856:#######################################
03-15 07:41:17.710: I/System.out(2877): Pointer ID 0
03-15 07:41:17.710: I/System.out(2877): Pointer X 550.87195
03-15 07:41:17.710: I/System.out(2877): Pointer Y 132.32227
03-15 07:41:17.710: I/System.out(2877): #######################################
03-15 07:41:17.730: I/System.out(2877): At time 12650869:#######################################
03-15 07:41:17.730: I/System.out(2877): Pointer ID 0
03-15 07:41:17.730: I/System.out(2877): Pointer X 607.1514
03-15 07:41:17.730: I/System.out(2877): Pointer Y 106.03476
03-15 07:41:17.730: I/System.out(2877): #######################################