示例#1
0
  public void paintResultCards(GLEx canvas) {
    RectF.Range src = new RectF.Range();
    RectF.Range des = new RectF.Range();
    int row;
    int col;

    for (int i = 0; i < cards.length; i++) {
      row = CardsManager.getImageRow(cards[i]);
      col = CardsManager.getImageCol(cards[i]);
      cardImage = Game.getImage(CardImage.cardImages[row][col]);
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      // 当玩家是NPC时,竖向绘制,扑克牌全是背面
      if (paintDirection == CardsType.direction_Vertical) {
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) (left * Game.SCALE_HORIAONTAL),
            (int) ((top - 40 + i * 15) * Game.SCALE_VERTICAL),
            (int) ((left + 40) * Game.SCALE_HORIAONTAL),
            (int) ((top + 20 + i * 15) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);

      } else {
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) ((left + 40 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) (top * Game.SCALE_VERTICAL),
            (int) ((left + 80 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top + 60) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);
      }
    }
  }
示例#2
0
  // 绘制玩家手中的牌
  public void paint(GLEx canvas) {
    //	System.out.println("id:" + playerId);
    RectF.Range src = new RectF.Range();
    RectF.Range des = new RectF.Range();

    int row;
    int col;

    // 当玩家是NPC时,竖向绘制,扑克牌全是背面
    if (paintDirection == CardsType.direction_Vertical) {
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      LTexture backImage = Game.getImage("card_bg");

      src.set(0, 0, backImage.getWidth(), backImage.getHeight());
      des.set(
          (int) (left * Game.SCALE_HORIAONTAL),
          (int) (top * Game.SCALE_VERTICAL),
          (int) ((left + 40) * Game.SCALE_HORIAONTAL),
          (int) ((top + 60) * Game.SCALE_VERTICAL));
      RectF.Range rectF = new RectF.Range(des);
      canvas.rect(rectF, 5, 5, paint);
      canvas.drawBitmap(backImage, src, des, paint);

      // 显示剩余牌数
      paint.setStyle(Style.FILL);
      paint.setColor(LColor.white);
      paint.setTextSize((int) (20 * Game.SCALE_HORIAONTAL));
      canvas.drawText(
          "" + cards.length,
          (int) (left * Game.SCALE_HORIAONTAL),
          (int) ((top + 80) * Game.SCALE_VERTICAL),
          paint);

    } else {
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      for (int i = 0; i < cards.length; i++) {
        row = CardsManager.getImageRow(cards[i]);
        col = CardsManager.getImageCol(cards[i]);
        cardImage = Game.getImage(CardImage.cardImages[row][col]);
        int select = 0;
        if (cardsFlag[i]) {
          select = 10;
        }
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) ((left + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top - select) * Game.SCALE_VERTICAL),
            (int) ((left + 40 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top - select + 60) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);
      }
    }
  }