예제 #1
0
  /**
   * 绘制死亡动画
   *
   * @param canvas
   */
  public void drawKilled(Canvas canvas) {
    // TODO Auto-generated method stub
    if (mKilledAnimIdx < mKilledAnimSize) {
      mKilledAnim.drawFrame(canvas, mPaint, mRect, mKilledAnimIdx);
    }
    if (mDrawNext % 5 == 0) {
      mKilledAnimIdx++;
    }
    mDrawNext++;
    if (mKilledAnimIdx >= mKilledAnimSize) {
      // 通知主界面game over
      Message msg = mHandler.obtainMessage();
      msg.what = MainActivity.MSG_GAME_OVER;
      mHandler.sendMessage(msg);

      // 播放 game over 声音
      Utils.sendSoundMsg(mHandler, R.raw.game_over);
    }
  }
예제 #2
0
 @Override
 public void drawKilled(Canvas canvas) {
   // TODO Auto-generated method stub
   if (mKilledAnim == null) {
     Bitmap[] bitmaps = Utils.getBigPlaneKilled(mContext);
     mKilledAnim = new Animation(bitmaps, false);
     mKilledAnimSize = bitmaps.length;
   }
   if (mKilledAnimIdx < mKilledAnimSize) {
     mKilledAnim.drawFrame(canvas, mPaint, mRect, mKilledAnimIdx);
   }
   if (mDrawNext % 2 == 0) {
     mKilledAnimIdx++;
   }
   mDrawNext++;
   if (mKilledAnimIdx >= mKilledAnimSize) {
     mKilledAnimIdx = IDX_KILLED_DEFAULT;
     reset();
   }
 }