我有一个大问题。我一直试图让触摸坐标持续数小时。但它没有奏效。我的代码是:
@Override
public boolean onTouchEvent(MotionEvent event)
{
if (event. getAction ()==MotionEvent.ACTION_DOWN){
touchx = event . getX ();
touchy= event . getY();
}
}
return true;
}
@Override
public void render()
{
touch=Gdx.input.isTouched();
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
if(touchx>2){
batch.draw(texture, Gdx.graphics.getWidth() / 4, 0,
Gdx.graphics.getWidth() / 2, Gdx.graphics.getWidth() / 2);
}
batch.end();
}
它不起作用。问题在哪里?
答案 0 :(得分:0)
@Override
public boolean dispatchTouchEvent(MotionEvent event){
int i=0;
i++;
System.out.println("-.-------------------X:"+event.getX()+"Y: "+event.getY());
return true;
}