固定区域中的多个位图

时间:2019-06-28 19:16:01

标签: android surfaceview android-bitmap

我正在尝试构建一个基于纸牌的游戏,在该游戏中,每回合后都会向玩家添加一张纸牌。为了赢得比赛玩家必须从他的牌组中删除所有卡牌。但是我还为其他目的画了一些额外的按钮。问题是,当卡片数量增加时,它们就会像下面的图像一样隐藏在按钮后面。

enter image description here

有什么方法可以在固定区域绘制位图?像下面的图像(卡片图像后面的突出显示的矩形)之类的东西。

enter image description here

以下是我为一位玩家绘制位图的代码

private void setMainPlayer() {
    //    Log.d(TAG, "Inside Set Main Player Method");
    Card localcard = null;
    Bitmap localimage = null;
    int currentiteration = 0;
    int Card_Gap = Screen_Width / 10;
    int Down_Card_Gap = 0;
    int Down_Card_Gap_positive = 0;
    int Down_Card_Gap_negative = 0;
    playerList.get(0).sortBySuit();

    //  Log.d(TAG,"Main Player Deck size"+MainPlayer.Count());
    while (currentiteration < playerList.get(0).decksize()) {
        localcard = playerList.get(0).getCard(currentiteration);
        localcard.setCurrent_Y(Screen_Height - localcard.getImage(context, Card_Width, Card_Height).getHeight());
        playerList.get(0).setCurrentCard(localcard, currentiteration);
        currentiteration++;
        if (Down_Card_Gap >= 0) {
            Down_Card_Gap_positive = Down_Card_Gap;
            localcard.setCurrent_X(Screen_Center_X + Down_Card_Gap_positive);
            Down_Card_Gap += Card_Gap;
        } else {
            Down_Card_Gap_negative = Down_Card_Gap;
            localcard.setCurrent_X(Screen_Center_X + Down_Card_Gap_negative);
        }
        Down_Card_Gap *= -1;

    }


}

private void DrawMainPlayerDeck(Canvas canvas) {
    // Log.d(TAG, " Inside Draw Main Player Deck");
    Card localcard;
    int currentiteration = 0;
    while (currentiteration < playerList.get(0).decksize()) {
        localcard = playerList.get(0).getCard(currentiteration);
        canvas.drawBitmap(localcard.getImage(context, Card_Width, Card_Height), localcard.getCurrent_X(), localcard.getCurrent_Y(), null);
        currentiteration++;
    }



}

我正在Surfaceview上绘制位图。

任何建议都会很有帮助。 预先感谢。

0 个答案:

没有答案