Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top