java - Android Touch Event - Having an Up Down and Move Event -
i have problem touch events sure possible.
lets have cube when swipe screen left or right want cube move same , when quick touch (down) want cube rotate amount.
currently if swipe screen cube move left or right want rotate once.
here code.
public boolean ontouchevent(motionevent event) { if (event != null) { float x = event.getx(); //float y = event.gety(); if (event.getaction() == motionevent.action_move) { if (mrenderer != null) { float cubex = (x - mpreviousx) / mdensity / 2f; mrenderer.mcubexmovement += cubex; } } else if (event.getaction() == motionevent.action_down) { if (mrenderer != null) { float deltax = 45f; mrenderer.mdeltax += deltax; } } mpreviousx = x; mpreviousy = y; return true; } else { return super.ontouchevent(event); } } the above code looks down event why rotates , moves on type of touch how implement cube rotate when down , event sequential
it's either down [ -> move ] -> or down [ -> move ] -> cancel
but action_up follows action_down
to check quick touch, mark down location (x&y) , make sure location within touch_slop (viewconfiguration.getscaledtouchslop()) of down location.
Comments
Post a Comment