Touch event in Gameview

Vabzboy

Member
Licensed User
Longtime User
In the animation "Catch the Bouncing Smiley" where upon touching the ball, the ball changes direction.

In Gameview, How would i implement this through the Touch event. It is working allright but when I touch the ball on its center or on its face nothing happens.

Anyway.. Can you guys help me out with what code should be correct for doing this.
 
In the Catch the Bouncing Smiley:

Code: Copy
Sub Activity_Touch(Action As Int, tx As Float, ty As Float)
   If Not(Action = Activity.ACTION_DOWN) Then Return
   If tx > x - boxSize AND tx < x + boxSize AND _
      ty > y - boxSize AND ty < y + boxSize Then
      vx = -vx 'change the smiley direction if the user pressed on it
      vy = -vy
   End If
   CircleCanvas.DrawCircle(tx, ty, 5dip, Colors.Red, False, 2dip)
   Activity.Invalidate3(tx - 7dip, ty - 7dip, tx + 7dip, ty + 7dip)
End Sub

Is this correct for Game view:

Code: Copy
Sub gv_Touch (Action As Int, X As Float, Y As Float)
If Not(Action = Activity.ACTION_DOWN) Then Return
   If X > smiley.DestRect.Right - size AND X < smiley.DestRect.Right AND _
      Y > smiley.DestRect.Bottom - size AND Y < smiley.DestRect.Bottom Then
      vx = -vx 'change the smiley direction if the user pressed on it
      vy = -vy
       
   End If
gv.Invalidate3(X - 7dip, Y - 7dip, X + 7dip, Y + 7dip)
      
End Sub
[/CODE]

I think something is wrong probably.
 
Upvote 0
Back
Top