コード例 #1
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   pointx = (float) event.getX();
   pointy = (float) event.getY();
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN: // 按下
       if (backgroundSound.isPointInRect(pointx, pointy)) { // 跳转到游戏界面
         backgroundSound.setswitch();
         activity.soundFlag = backgroundSound.isOnflag(); // 设置声音的开启,关闭
       } else if (soundEffect.isPointInRect(pointx, pointy)) {
         soundEffect.setswitch();
         activity.soundPoolFlag = soundEffect.isOnflag();
       }
       break;
     case MotionEvent.ACTION_UP: // 抬起
       break;
   }
   return true;
 }