触摸位置的java Blackberry触摸事件检测对象
这是我的第一个黑莓应用,我正在尝试为触摸屏设备制作一个简单的游戏。 这是典型的图像分割成瓷砖,你必须解读它们,使瓷砖的顺序正确,并显示图片。 这样做的目的是,用户将能够在屏幕上的任何位置“拖动”一个磁贴,并将其与放置的磁贴交换位置
我正在为我的互动程序使用位图按钮
HorizontalFieldManager hfm = new HorizontalFieldManager();
add(hfm);
hfm.add(button1);
hfm.add(button2);
etc...
我有一个叫做拼图屏幕的课程,如下所示:
class PuzzleScreen extends MainScreen implements FieldChangeListener {
我添加了以下内容,以尝试检测屏幕上触摸的人员的移动
protected boolean touchEvent(TouchEvent event) {
case TouchEvent.MOVE:
PuzzleTile fieldMove = (PuzzleTile) this.getLeafFieldWithFocus();
// Dialog.alert("MOVE");
int[] x_points;
int[] y_points;
int[] time_points;
int size = event.getMovePointsSize();
x_points = new int[size];
y_points = new int[size];
time_points = new int[size];
event.getMovePoints(1, x_points, y_points, time_points);
return true;
}
return false;
}
我需要找到哪个图像块(bitmapbutton)位于upevent的位置。 我有上面的坐标(我想),但不确定如何找到与之相关的瓷砖
贝克斯
# 1 楼答案
像这样的