android多点触控使用声音池

时间:2014-03-07 16:25:34

标签: android multi-touch soundpool

我不确定如何正确使用onTouch。现在我可以按一个图像播放声音,但我不能一次播放两个声音,也不能用手指向下滑动播放所有声音,它只播放按下的第一个图像。我知道这是因为onTouch和Multitouch,但我不知道如何做到这一点,我找不到任何相关的示例代码,任何帮助表示赞赏!

此代码onTouch,但我需要多点触控

 public boolean onTouch(View v, MotionEvent event) {

        if (event.getAction() == MotionEvent.ACTION_DOWN  ) {
             if(v.getId()==R.id.sagatup){

                if (loaded) {
                    soundPool.play(soundID, volume, volume, 1, 0, 1f);
                    Log.e("Test", "Played sound");
                }

             }
             if(v.getId()==R.id.sagatdown){

                if (loaded) {
                    soundPool.play(soundID2, volume, volume, 1, 0, 1f);
                    Log.e("Test", "Played sound");
                }
             }
             if(v.getId()==R.id.clap){

                // Is the sound loaded already?
                if (loaded) {
                    soundPool.play(soundID3, volume, volume, 1, 0, 1f);
                    Log.e("Test", "Played sound");
                }
             }
             if(v.getId()==R.id.za3rota){

                    // Is the sound loaded already?
                    if (loaded) {
                        soundPool2.play(soundID4, volume, volume, 1, 0, 1f);
                        Log.e("Test", "Played sound");
                    }
             }

        }

        return false;
    }

1 个答案:

答案 0 :(得分:0)

更改return false;至 return true;