3

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.

SwapnilPopat
  • 517
  • 5
  • 26
Jigar Shekh
  • 2,800
  • 6
  • 29
  • 54
  • 1
    well, that is much declarative answer than your tinny question, as equal as another tutorial.What have you tried so far? – ridoy Feb 10 '14 at 10:19
  • @ridoy i try to using touch listener. but i not work done by me.Please help me. – Jigar Shekh Feb 10 '14 at 10:28

1 Answers1

3

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.

ridoy
  • 6,274
  • 2
  • 29
  • 60