在我移开手指后,我正试图分离一条线,所以在 ACTION_UP .. 它似乎不起作用
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
mScene = new Scene();
mScene.setOnSceneTouchListener(new IOnSceneTouchListener() {
@Override
public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
if(pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
isDrawing = true;
i = 0;
}
if (isDrawing = true) {
rec[i] = new Rectangle(pSceneTouchEvent.getX(), pSceneTouchEvent.getY(), 1, 1, getVertexBufferObjectManager());
if (i != 0) {
l = new Line(rec[i-1].getX(), rec[i-1].getY(), rec[i].getX(), rec[i].getY(), getVertexBufferObjectManager());
l.setColor(0.5f, 1f, 0.3f);
mScene.attachChild(l);
}
i++;
}
if(pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) {
isDrawing = false;
mScene.detachChild(l);
}
return true;
}
});
pOnCreateSceneCallback.onCreateSceneFinished(mScene);
}
在 ACTION_DOWN 中,它会用我的手指画线,但在 ACTION_UP 中,线应该分离,为什么不是?