Reputation: 2810
I refer this link Bouncing Ball.When user touch on ball, it stops moving & When user release ball then it continues moving. how can we do it using touch gesture ?
Thank you in Advance.
Upvotes: 3
Views: 763
Reputation: 6332
As i said earlier that is much declarative answer to help you here.You need to share your code here to help something.
I would like to give you some hint to do this: override onTouchEvent(MotionEvent event)
method. Use event.getAction()
to catch various MotionEvent
. When you can identify MotionEvent.ACTION_DOWN
then set event.getX()
and getY()
as your objects current x,y. That will stop moving your object.
Similarly, at MotionEvent.ACTION_UP
update your objects position(x,y according to the direction), and set yourObject.setTouched(false)
. So when user release his finger from the screen object will start to move again.
Upvotes: 3