Hello all,

I was exploring the Snake game sample code (from the revision 10
directory of the SDK) and found that there was no touch support
integrated.  I have a Nexus S, so I decided for practice I would add
touch control support to the project; my original idea was to put an
onTouchEvent method in the SnakeView class and have the method check
the coordinates of the touch against the coordinates of the snake's
head to determine what direction it should turn.  This didn't work
because, as I found out through logging the coordinates of both the
snake's head and the touch events, the snake is effectively operating
on a different coordinate plane from that of the SnakeView view
receiving the touch events.  I can see that the snake has its own
custom Coordinate nested class in SnakeView, and that the drawing
called by the update methods occurs in TileView, but I don't quite see
how the x and y values fed in to the Coordinate class correspond to
the actual view coordinates... the default values where the snake
begins, around 7,3 by the Coordinate class's reckoning, are actually
around 90,40 on the view's coordinate plane.  Can someone explain
exactly how the Coordinate nested class's x and y values are being
mapped to the view's actual coordinates and/or how I can alter the
Coordinate class (or maybe one of the update methods or the onDraw
method in TileView) so that the coordinates of the snake's tiles lie
on the SnakeView view's coordinate plane?

thanks,
CCJ

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to