我是AndEngineonSceneTouchEvent
的新手,我想用我的手指坐标画一条线t 检测到问题:/
private Scene scene;
float startX;
float startY;
float lastX;
float lastY;
int lineUsageCount = 0;
@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
switch (pSceneTouchEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
startX = pSceneTouchEvent.getX();
startY = pSceneTouchEvent.getY();
lineUsageCount = 0 ;
break;
case MotionEvent.ACTION_MOVE:
lineUsageCount++;
lastX = pSceneTouchEvent.getX();
lastY = pSceneTouchEvent.getY();
break;
case MotionEvent.ACTION_UP:
if (lineUsageCount <= 5) {
final Line line = new Line(startX, startY, lastX,
lastY, this.getVertexBufferObjectManager());
line.setLineWidth(1);
line.setColor(255, 255, 255);
scene.attachChild(line);
}
break;
}
return true;
}
};
它应该得到第一个坐标startX, startY
,然后Action_Move
它得到lastX, lastY
并画线,但它似乎不起作用:|