Пример #1
0
 // 先从存储卡加载图片,没找到则取默认
 public void CreateBM(Resources res, int i) {
   card[i] =
       CreateBitMap.scaleBitmap(
           "card" + i + ".jpg", (int) (iCardWidth * fWidthRate), (int) (iCardHigth * fHigthRate));
   if (card[i] == null) {
     int indentify = res.getIdentifier("ken.lai:drawable/card" + i, null, null);
     card[i] =
         CreateBitMap.scaleBitmap(
             res, indentify, (int) (iCardWidth * fWidthRate), (int) (iCardHigth * fHigthRate));
   }
 }
Пример #2
0
  // 初始化
  public void init(Resources res, int iCardWidth, int iCardHigth) {
    // 根据屏幕的宽度和高度,适当的来决定牌的宽度和高度
    fWidthRate = (float) (iCardWidth) / 800;
    fHigthRate = (float) (iCardHigth) / 480;

    bg =
        CreateBitMap.scaleBitmap(
            res, R.drawable.bgm, (int) (800 * fWidthRate), (int) (480 * fHigthRate));
    help =
        CreateBitMap.scaleBitmap(
            res, R.drawable.bhelp, (int) (100 * fWidthRate), (int) (60 * fHigthRate));
    start =
        CreateBitMap.scaleBitmap(
            res, R.drawable.bstart, (int) (100 * fWidthRate), (int) (60 * fHigthRate));
    exit =
        CreateBitMap.scaleBitmap(
            res, R.drawable.bexit, (int) (100 * fWidthRate), (int) (60 * fHigthRate));
  }
Пример #3
0
  // 洗牌
  public void reset() {
    bResetOK = false;
    iSelectCard1 = -1;
    iSelectCard2 = -1;
    iOver = 0;
    itimeleft = timemax;
    timelast = System.currentTimeMillis();
    iNowSucc = 0;
    iSucc = 0;
    iClick = 0;
    iHeihei = 0;

    // 根据关卡挑战游戏布局难道
    if (CCV.iSelect <= 3) {
      iRows = 4;
      iCols = 6;
      iCardCnt = 6;
    } else if (CCV.iSelect <= 8) {
      iRows = 4;
      iCols = 7;
      iCardCnt = 7;
    } else if (CCV.iSelect <= 12) {
      iRows = 4;
      iCols = 8;
      iCardCnt = 8;
    } else if (CCV.iSelect <= 18) {
      iRows = 5;
      iCols = 8;
      iCardCnt = 9;
    } else {
      iRows = 5;
      iCols = 8;
      iCardCnt = 10;
    }

    if (model == 1) {
      iCardCnt = 10;
      iRows = 4;
      iCols = 7;
    }

    iCardWidth = (800 - ctrl - iBlank * (iCols + 1)) / iCols;
    iCardHigth = (480 - ads - iBlank * (iRows + 1)) / iRows;
    bmCardSelect =
        CreateBitMap.scaleBitmap(
            m_res,
            R.drawable.select,
            (int) (iCardWidth * fWidthRate),
            (int) (iCardHigth * fHigthRate));
    bmCardBg =
        CreateBitMap.scaleBitmap(
            m_res,
            R.drawable.cardbg,
            (int) (iCardWidth * fWidthRate),
            (int) (iCardHigth * fHigthRate));

    // 因为图片的大小变化了,需要重新生成
    for (int i = 1; i <= 10; i++) {
      CreateBM(m_res, i);
    }

    int tmp[] = new int[iCardCnt + 1];
    for (int i = 0; i < iCardCnt + 1; i++) tmp[i] = 0;
    for (int i = 1; i <= iRows; i++) {
      for (int j = 1; j <= iCols; j++) {
        int iSeq = (i - 1) * iCols + j;
        game[iSeq] = new CGuessUnit();
        boolean bFind = false;
        if (iSeq > ((iRows * iCols) - iCardCnt)) {
          for (int itmp = 1; itmp < iCardCnt + 1; itmp++) {
            if (tmp[itmp] % 2 == 1) {
              // game[iSeq].card = card[itmp];
              game[iSeq].card = itmp;
              tmp[itmp]++;
              bFind = true;
              break;
            }
          }
        }

        if (!bFind) {
          int iRand = Math.abs(rdm.nextInt()) % iCardCnt + 1;
          tmp[iRand]++;
          // game[iSeq].card = card[iRand];
          game[iSeq].card = iRand;
        }

        // 布局中一张牌的坐标,点击事件中根据这个来判断
        int iBlankTmp = (int) ((iBlank) * fHigthRate);
        game[iSeq].iLeft = (j - 1) * ((int) (iCardWidth * fWidthRate) + iBlankTmp) + iBlankTmp;
        game[iSeq].iRight = game[iSeq].iLeft + (int) (iCardWidth * fWidthRate);
        game[iSeq].iTop =
            (i - 1) * ((int) (iCardHigth * fHigthRate) + iBlankTmp)
                + iBlankTmp
                + (int) (ads * fHigthRate) * iShowFlag;
        game[iSeq].iBottom = game[iSeq].iTop + (int) (iCardHigth * fHigthRate);
      }
    }
    bResetOK = true;
  }
Пример #4
0
  public void init(CaicaiView ccv, Resources res, int iWidthT, int iHigthT) {
    CCV = ccv;
    m_iWidthT = iWidthT;
    m_iHigthT = iHigthT;
    m_res = res;
    // 根据屏幕的宽度和高度,适当的来决定牌的宽度和高度
    fWidthRate = (float) (iWidthT) / 800;
    fHigthRate = (float) (iHigthT) / 480;

    // 背景按钮等
    bmDian =
        CreateBitMap.scaleBitmap(
            res, R.drawable.dian, (int) (800 * fWidthRate), (int) (480 * fHigthRate));
    bg =
        CreateBitMap.scaleBitmap(
            res, R.drawable.bg, (int) (800 * fWidthRate), (int) (480 * fHigthRate));
    daoju =
        CreateBitMap.scaleBitmap(
            res, R.drawable.daoju, (int) (70 * fWidthRate), (int) (200 * fHigthRate));
    df =
        CreateBitMap.scaleBitmap(
            res, R.drawable.df, (int) (55 * fWidthRate), (int) (60 * fHigthRate));
    db =
        CreateBitMap.scaleBitmap(
            res, R.drawable.db, (int) (55 * fWidthRate), (int) (60 * fHigthRate));
    dd =
        CreateBitMap.scaleBitmap(
            res, R.drawable.dd, (int) (55 * fWidthRate), (int) (60 * fHigthRate));
    reset =
        CreateBitMap.scaleBitmap(
            res, R.drawable.reset, (int) (100 * fWidthRate), (int) (60 * fHigthRate));
    back =
        CreateBitMap.scaleBitmap(
            res, R.drawable.back, (int) (100 * fWidthRate), (int) (60 * fHigthRate));
    open =
        CreateBitMap.scaleBitmap(
            res, R.drawable.open, (int) (100 * fWidthRate), (int) (60 * fHigthRate));
    close =
        CreateBitMap.scaleBitmap(
            res, R.drawable.close, (int) (100 * fWidthRate), (int) (60 * fHigthRate));
    timebar =
        CreateBitMap.scaleBitmap(
            res, R.drawable.timebar, (int) (12 * fWidthRate), (int) (470 * fHigthRate));
    timeleft =
        CreateBitMap.scaleBitmap(
            res, R.drawable.timeleft, (int) (29 * fWidthRate), (int) (32 * fHigthRate));
    over1 =
        CreateBitMap.scaleBitmap(
            res, R.drawable.over1, (int) (200 * fWidthRate), (int) (150 * fHigthRate));
    over2 =
        CreateBitMap.scaleBitmap(
            res, R.drawable.over2, (int) (200 * fWidthRate), (int) (150 * fHigthRate));
    bfeng =
        CreateBitMap.scaleBitmap(
            res, R.drawable.feng, (int) (25 * fWidthRate), (int) (25 * fHigthRate));
    ice =
        CreateBitMap.scaleBitmap(
            res, R.drawable.ice, (int) (12 * fWidthRate), (int) (470 * fHigthRate));

    // 初始化所有牌资源
    card = new Bitmap[11];

    // 初始化牌布局,5*8为最大布局
    game = new CGuessUnit[5 * 8 + 1];
    reset();
  }