Wednesday, September 29, 2010

[android-developers] Re: Multi-touch for a Piano

Hi Bart,
I need a little push... I have figured out that once you have the
view...do view.addview(button1); but how do you see each button with
the ontouch? a simple example would be great, thanks!
Jake

On Sep 26, 4:08 am, a1 <arco...@gmail.com> wrote:
> I think you should first take a look at:http://developer.android.com/reference/android/view/ViewGroup.html#on...)
> and here:http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...
>
> I really think that this can be solved on framework level without
> changing whole layout.
>
> --
> Bart Janusz
>
> On 26 Wrz, 09:48,ArcDroid<jacobrjohn...@gmail.com> wrote:
>
>
>
> > Thanks Robert,
> > Sure which I could simply use the multitouch with multiple views.
> > Looks like I am going to have one heck of a time mapping all the
> > locations of the keys.
> > Jake
>
> > On Sep 6, 10:01 pm, Robert Green <rbgrn....@gmail.com> wrote:
>
> > >ArcDroid,
>
> > > I would do the following:
>
> > > Mock up the screen in a graphics creation/editing application.  Slice
> > > out the parts that you're going to use for your app.
>
> > > Create a custom view.  I use surfaceview if it's going to be primary.
>
> > > Load all of your assets and draw them to the screen.  Tweak to get it
> > > to work right.
>
> > > Now write your touch handling code.  Mostly you'll want to look for
> > > touch downs (**note on that for multitouch below) and trigger a sound
> > > on a touchdown point intersecting a key.
>
> > > For multitouch, when the second touch point comes down you won't get a
> > > down event but instead will have a move event with 2 touch points in
> > > it instead just one.  There is a flaw in the implementation of the API
> > > though that no event is sent when the second touch point is lifted.
> > > You'll only find out when the first touch point has moved, as the
> > > event will have a pointer count of 1 instead of 2 like it did
> > > previously.  That may not have much of an impact on your app but
> > > knowing to look for the pointer count going from 1 to 2 is key for
> > > you.
>
> > > A quick and dirty way to implement MT of any number of touches
> > > (Remember - some new phones support up to 5 touchpoints) is to keep an
> > > array of the keys and their states (up or down).  If touch down or
> > > movement is occuring in any of those keys where the state is up, set
> > > the state to down and trigger the sound.  If no touch is intersecting
> > > a key's bounds, set the state to up.  This also makes for nice
> > > rendering since all you have to do is draw an alternate image for the
> > > current down keys.
>
> > > Good luck and have fun with your app
>
> > > On Sep 6, 10:12 pm,ArcDroid<jacobrjohn...@gmail.com> wrote:
>
> > > > Hello,
> > > > I would like to add multi-touch to my piano app and would like
> > > > feedback on the best way to do it.  I hate the idea that multi-touch
> > > > is only for one view and not multiple views (ie buttons).
> > > > Thanks,
> > > > Jake- Hide quoted text -
>
> - Show quoted text -

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment