HI,
I’m new in game development.I have an image with design like PLAY, LEARN,etc… in the image of Home screen.
I want to click over the specific PLAY to start the game OR over LEARN to get the idea of game.I’m struck in this click feature .
How can i retrieve specific coordinates from static image to start different UI screens.Image attached. I want to lick over play to start new Activity.Similarly for other (learn,more games,Help).
Looking for help…..Urgently.Thanks in Advance.
-Rgds,
praween!
You can do this by overriding the Activity’s ‘dispatchTouchEvent.’ You will receive a MotionEvent which has 2 functions you can use to get the Pixel coords of the click.
The trick on Android is that these x and y values will be in pixels. Since you don’t know what the resolution of the device you are using will be ahead of time, you can’t always say that 100 pixels is just above the balloon. It is best to do these types of things in a resolution independent value, like always pretending the screen is 480×320 and converting all the values into that range.
Android has units it calls ‘dp’ which are based on the same concept and are used when laying out views. You can read more about this here:
http://developer.android.com/guide/practices/screens_support.html