[android-developers] Re: Programming a target in an Android Application

2010-09-06 Thread kingh32
Thought I would post back and say thanks for helping me program the
target.
It was very straightforward in the end. And if someone else 'Googles'
it in the future this is bound to come up!

Identify the centre point, then use the X and Y coordinates of it as a
correction factor
Use Pythagoras theorem  to calculate the hypotenuse of the triangle
i.e. the longest side of an imaginary triangle that exists based on
the coordinates
recorded when somebody touches the screen.
Award different points or do different things based on this length.

Cheers guys

On Aug 3, 9:47 pm, kingh32 horaceb1...@gmail.com wrote:
 Thanks, both of you for your help.
 I imagine I'll be back with more questions soon!

 On Aug 3, 8:08 pm, Bob Kerns r...@acm.org wrote:



  Everything -- both the positions and the image widget size -- will be
  in pixel coordinates. Actually, you don't need to know that -- just
  that they're the same. Hell, I could even be wrong; I'm not going to
  take out a microscope and check.

  If you have different coordinates for your image data (or even if you
  don't or don't know or might want to scale in the future or are
  paranoid), simply scale by the ratio of the image data : image widget.
  A scale factor of 1:1 won't cause you any trouble.

  There are times to be absolute, and times to be relative. This is one
  of the latter.

  On Aug 3, 9:25 am, kingh32 horaceb1...@gmail.com wrote:

   Hello - Thanks for your reply!

   What you have just mentioned is pretty much where I'm stuck!
   I don't know how to identify programatically where the target actually
   is. Would this be done using pixel coordinates?
   Is there a way to determine the resolution of the phone (screen) that
   the app is being run on and adjust these calculations accordingly?

   Thanks

   On Aug 3, 4:52 pm, TreKing treking...@gmail.com wrote:

On Tue, Aug 3, 2010 at 4:05 AM, Horace Bell-Gam 
horaceb1...@gmail.comwrote:

 No, so far all I've been able to do is overlay an image of the target 
 and
 make the entire object respond to a click.

You know:
- The center of the image
- The length of each band
- Where the user clicks on the image (via onTouchEvents, me thinks)
- Simple algebra to calculate the distance of a point from the center 
of the
image (I hope)

That's all you should need to figure out which band the user has 
touched.

What have you tried thus far? Where are you stuck?

---
 --
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
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


[android-developers] Re: Programming a target in an Android Application

2010-08-03 Thread kingh32
Hello - Thanks for your reply!

What you have just mentioned is pretty much where I'm stuck!
I don't know how to identify programatically where the target actually
is. Would this be done using pixel coordinates?
Is there a way to determine the resolution of the phone (screen) that
the app is being run on and adjust these calculations accordingly?

Thanks

On Aug 3, 4:52 pm, TreKing treking...@gmail.com wrote:
 On Tue, Aug 3, 2010 at 4:05 AM, Horace Bell-Gam horaceb1...@gmail.comwrote:

  No, so far all I've been able to do is overlay an image of the target and
  make the entire object respond to a click.

 You know:
 - The center of the image
 - The length of each band
 - Where the user clicks on the image (via onTouchEvents, me thinks)
 - Simple algebra to calculate the distance of a point from the center of the
 image (I hope)

 That's all you should need to figure out which band the user has touched.

 What have you tried thus far? Where are you stuck?

 --- 
 --
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

-- 
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


Re: [android-developers] Re: Programming a target in an Android Application

2010-08-03 Thread TreKing
On Tue, Aug 3, 2010 at 11:25 AM, kingh32 horaceb1...@gmail.com wrote:

 Would this be done using pixel coordinates?


I guess.


  Is there a way to determine the resolution of the phone (screen) that
 the app is being run on and adjust these calculations accordingly?


http://developer.android.com/reference/android/util/DisplayMetrics.html

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
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

Re: [android-developers] Re: Programming a target in an Android Application

2010-08-03 Thread TreKing
On Tue, Aug 3, 2010 at 11:25 AM, kingh32 horaceb1...@gmail.com wrote:

 Is there a way to determine the resolution of the phone (screen) that the
 app is being run on and adjust these calculations accordingly?


Also, if I were you, I'd start by simply hard-coding a known size (like that
of whatever device you have) and getting it to work first.

Then, once that's done, do the second part of figuring out the actual width
/ height based on device properties.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
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

[android-developers] Re: Programming a target in an Android Application

2010-08-03 Thread Bob Kerns
Everything -- both the positions and the image widget size -- will be
in pixel coordinates. Actually, you don't need to know that -- just
that they're the same. Hell, I could even be wrong; I'm not going to
take out a microscope and check.

If you have different coordinates for your image data (or even if you
don't or don't know or might want to scale in the future or are
paranoid), simply scale by the ratio of the image data : image widget.
A scale factor of 1:1 won't cause you any trouble.

There are times to be absolute, and times to be relative. This is one
of the latter.

On Aug 3, 9:25 am, kingh32 horaceb1...@gmail.com wrote:
 Hello - Thanks for your reply!

 What you have just mentioned is pretty much where I'm stuck!
 I don't know how to identify programatically where the target actually
 is. Would this be done using pixel coordinates?
 Is there a way to determine the resolution of the phone (screen) that
 the app is being run on and adjust these calculations accordingly?

 Thanks

 On Aug 3, 4:52 pm, TreKing treking...@gmail.com wrote:



  On Tue, Aug 3, 2010 at 4:05 AM, Horace Bell-Gam 
  horaceb1...@gmail.comwrote:

   No, so far all I've been able to do is overlay an image of the target and
   make the entire object respond to a click.

  You know:
  - The center of the image
  - The length of each band
  - Where the user clicks on the image (via onTouchEvents, me thinks)
  - Simple algebra to calculate the distance of a point from the center of the
  image (I hope)

  That's all you should need to figure out which band the user has touched.

  What have you tried thus far? Where are you stuck?

  --- 
  --
  TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
  transit tracking app for Android-powered devices

-- 
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


[android-developers] Re: Programming a target in an Android Application

2010-08-03 Thread kingh32
Thanks, both of you for your help.
I imagine I'll be back with more questions soon!

On Aug 3, 8:08 pm, Bob Kerns r...@acm.org wrote:
 Everything -- both the positions and the image widget size -- will be
 in pixel coordinates. Actually, you don't need to know that -- just
 that they're the same. Hell, I could even be wrong; I'm not going to
 take out a microscope and check.

 If you have different coordinates for your image data (or even if you
 don't or don't know or might want to scale in the future or are
 paranoid), simply scale by the ratio of the image data : image widget.
 A scale factor of 1:1 won't cause you any trouble.

 There are times to be absolute, and times to be relative. This is one
 of the latter.

 On Aug 3, 9:25 am, kingh32 horaceb1...@gmail.com wrote:



  Hello - Thanks for your reply!

  What you have just mentioned is pretty much where I'm stuck!
  I don't know how to identify programatically where the target actually
  is. Would this be done using pixel coordinates?
  Is there a way to determine the resolution of the phone (screen) that
  the app is being run on and adjust these calculations accordingly?

  Thanks

  On Aug 3, 4:52 pm, TreKing treking...@gmail.com wrote:

   On Tue, Aug 3, 2010 at 4:05 AM, Horace Bell-Gam 
   horaceb1...@gmail.comwrote:

No, so far all I've been able to do is overlay an image of the target 
and
make the entire object respond to a click.

   You know:
   - The center of the image
   - The length of each band
   - Where the user clicks on the image (via onTouchEvents, me thinks)
   - Simple algebra to calculate the distance of a point from the center of 
   the
   image (I hope)

   That's all you should need to figure out which band the user has touched.

   What have you tried thus far? Where are you stuck?

   ---
--
   TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
   transit tracking app for Android-powered devices

-- 
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