Esempio n. 1
0
 protected void onDestroy() {
   // TODO Auto-generated method stub
   super.onDestroy();
   // 关闭音乐
   if (Set.isMusic() && music.isPlaying() && destory) {
     Music.stop();
   }
 }
Esempio n. 2
0
 @Override
 protected void onResume() {
   // TODO Auto-generated method stub
   Log.i("tag", "onResume");
   super.onResume();
   isPause = false;
   // 重启音乐
   if (Set.isMusic() && (!music.isPlaying())) {
     Music.play();
   }
 }
Esempio n. 3
0
  @Override
  public void onPause() {
    // TODO Auto-generated method stub
    Log.i("tag", "onPause");
    super.onPause();

    // 暂停音乐
    if (Set.isMusic() && (!destory) && music.isPlaying()) {
      Music.pause();
    }

    // 转到暂停界面
    if ((!isPause) && (!destory)) {
      Intent intent = new Intent();
    }
  }
Esempio n. 4
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   // TODO Auto-generated method stub
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     destory = true;
     Music.pause();
     new AlertDialog.Builder(this)
         .setTitle("退出游戏")
         .setMessage("当前退出,游戏以失败结束...")
         // .setIcon(R.drawable.quit)
         .setPositiveButton(
             "放弃",
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int whichButton) {
                 // System.out.println(handler.sendEmptyMessage(2));
                 startActivity(new Intent(MatchActivity.this, EndActivity.class));
                 MatchActivity.this.finish();
               }
             })
         .setNegativeButton(
             "取消",
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int whichButton) {
                 // 取消按钮事件
                 destory = false;
                 Music.play();
               }
             })
         .show();
   }
   return super.onKeyDown(keyCode, event);
 }
Esempio n. 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    WindowManager manager = getWindowManager();
    width = manager.getDefaultDisplay().getWidth();
    setContentView(R.layout.activity_main);

    isPause = false;
    destory = false;

    pb = (NumberSeekBar) findViewById(R.id.bar0);
    mPref = getSharedPreferences("settime", MODE_PRIVATE);
    String num = mPref.getString("settime", "");
    if (TextUtils.isEmpty(num)) {
      pb.setMax(max);
    } else {
      max1 = Integer.parseInt(num);
      pb.setMax(max1);
    }
    init();
    start();

    exView = (ExView) this.findViewById(R.id.exView);
    this.hint = (TextView) this.findViewById(R.id.textView);
    hint.setText(SString.getString(exView.getFigure().getIndex()));
    exView.setHint(hint);

    resert = (Button) findViewById(R.id.reset);
    resert.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            AnimationSet animationSet = new AnimationSet(true);
            ScaleAnimation scaleAnimation =
                new ScaleAnimation(
                    0.8f,
                    0.8f,
                    0.8f,
                    0.8f,
                    Animation.RELATIVE_TO_SELF,
                    0.6f,
                    Animation.RELATIVE_TO_SELF,
                    0.6f);

            scaleAnimation.setAnimationListener(
                new AnimationListener() {

                  @Override
                  public void onAnimationStart(Animation animation) {
                    // TODO Auto-generated method stub
                  }

                  @Override
                  public void onAnimationRepeat(Animation animation) {
                    // TODO Auto-generated method stub

                  }

                  @Override
                  public void onAnimationEnd(Animation animation) {
                    // TODO Auto-generated method stub
                    exView.reset();
                  }
                });

            // AssetsLoad.playSound(getApplicationContext(), AssetsLoad.dropSoundId);
            animationSet.addAnimation(scaleAnimation);
            animationSet.setFillBefore(true);
            animationSet.setDuration(100);
            resert.startAnimation(animationSet);
          }
        });

    pause = (Button) findViewById(R.id.stop);
    pause.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            // TODO Auto-generated method stub
            AnimationSet animationSet = new AnimationSet(true);
            ScaleAnimation scaleAnimation =
                new ScaleAnimation(
                    0.9f,
                    0.9f,
                    0.9f,
                    0.9f,
                    Animation.RELATIVE_TO_SELF,
                    0.6f,
                    Animation.RELATIVE_TO_SELF,
                    0.6f);

            animationSet.addAnimation(scaleAnimation);
            animationSet.setFillBefore(true);
            animationSet.setDuration(100);
            pause.startAnimation(animationSet);
            if (stopCount % 2 == 0) {
              pause.setBackgroundResource(R.drawable.play);
              destory = true;
              hint.setVisibility(View.INVISIBLE);
              exView.setVisibility(View.INVISIBLE);
            } else {
              pause.setBackgroundResource(R.drawable.pause);
              destory = false;
              hint.setVisibility(View.VISIBLE);
              exView.setVisibility(View.VISIBLE);
            }
            stopCount++;
          }
        });

    home = (Button) findViewById(R.id.home);
    // 设置音乐
    music = new Music(this);
    if (Set.isMusic()) {
      Music.play();
      home.setBackgroundResource(R.drawable.sopen);
      home.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View arg0) {
              AnimationSet animationSet = new AnimationSet(true);
              ScaleAnimation scaleAnimation =
                  new ScaleAnimation(
                      0.9f,
                      0.9f,
                      0.9f,
                      0.9f,
                      Animation.RELATIVE_TO_SELF,
                      0.6f,
                      Animation.RELATIVE_TO_SELF,
                      0.6f);

              animationSet.addAnimation(scaleAnimation);
              animationSet.setFillBefore(true);
              animationSet.setDuration(100);
              home.startAnimation(animationSet);

              Set.setnewMusic();

              // 声音的开启与关闭
              if (SoundInt % 2 == 0) {
                home.setBackgroundResource(R.drawable.sclose);
                // 关闭音乐
                Music.pause();
                Set.disMusic();
              } else {
                home.setBackgroundResource(R.drawable.sopen);
                // 开启音乐
                Music.play();
                Set.setnewMusic();
              }
              SoundInt++;
            }
          });
    } else {
      // Music.pause();
      home.setBackgroundResource(R.drawable.sclose);
      home.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View arg0) {
              AnimationSet animationSet = new AnimationSet(true);
              ScaleAnimation scaleAnimation =
                  new ScaleAnimation(
                      0.9f,
                      0.9f,
                      0.9f,
                      0.9f,
                      Animation.RELATIVE_TO_SELF,
                      0.6f,
                      Animation.RELATIVE_TO_SELF,
                      0.6f);

              animationSet.addAnimation(scaleAnimation);
              animationSet.setFillBefore(true);
              animationSet.setDuration(100);
              home.startAnimation(animationSet);
              Set.isMusic();
              Set.setnewMusic();
              Music.play();

              // 声音的开启与关闭
              if (SoundInt % 2 == 0) {
                home.setBackgroundResource(R.drawable.sopen);
                // 开启音乐
                Music.play();
                Set.setnewMusic();
              } else {
                home.setBackgroundResource(R.drawable.sclose);
                // 关闭音乐
                Music.pause();
                Set.disMusic();
              }
              SoundInt++;
            }
          });
    }
  }