开发者

How enable multi touch for dragging events

开发者 https://www.devze.com 2023-02-10 10:58 出处:网络
How do I enable multitouch support fo开发者_如何学Pythonr an app, I wish two users touching the screen and both sending drag events for the aplication.

How do I enable multitouch support fo开发者_如何学Pythonr an app, I wish two users touching the screen and both sending drag events for the aplication.

I have this code on my component

public boolean onTouchEvent(MotionEvent evt) {
        if (evt.getY() > 612) {
            east.notifyMotionEvent(evt);
            south.notifyMotionEvent(evt);
        } else {
            weast.notifyMotionEvent(evt);
            north.notifyMotionEvent(evt);
        }

        return true;
}

But only one drag event is being send to it.

My code to support now is

        for (int i = 0; i < evt.getPointerCount(); i++) {
            float y = evt.getY(i);
            if (y > 612) {
                eastPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
                southPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
            } else {
                weastPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
                northPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
            }
        }


It's enabled in your AndroidManifest.xml file.

 <uses-feature android:name="android.hardware.touchscreen.multitouch"
               android:required="true" />

More info: http://developer.android.com/guide/topics/manifest/uses-feature-element.html

0

精彩评论

暂无评论...
验证码 换一张
取 消