如何将TextureRegion添加到对象参数

时间:2018-10-20 08:46:18

标签: java android libgdx

我用Cardatlas拍摄纸牌的图像,并将其放在textureregion中。我有一个纸牌对象,其中包含有关纸牌颜色及其编号的信息。如何在此卡的图片上添加第三个选项

  

`

public enum Color {
        Red("red", 0), Yellow("yellow", 1), Green("green", 2), Blue("blue", 3);
        public final String name;
        public final int index;

        private Color(String name, int index) {
            this.name = name;
            this.index = index;
        }
    }

    public enum Purpose {
        Zero(1), One(2), Two(3), Three(4), Four(5), Five(6), Six(7), Seven(8), Hlop(9), Poli(10), Hap(11), Per(12), Zah(13);
        public final int value;
        public final int index;

        private Purpose(int value) {
            this.value = value;
            this.index = value - 1;
        }
    }



    public static class Card {
        public final Color color;
        public final Purpose purpose;

        public Card(Color color, Purpose purpose, Sprite front) {
            this.color = color;
            this.purpose = purpose;
            front.setPosition(-front.getWidth() * 0.5f, -front.getHeight() * 0.5f);

        }
    }

    public static class CardDeck {
        private final Card[][] cards;

        public CardDeck(TextureAtlas atlas) {
            cards = new Card[Color.values().length][];
            for (Color color : Color.values()) {
                cards[color.index] = new Card[Purpose.values().length];
                for (Purpose purpose : Purpose.values()) {
                    Sprite front = atlas.createSprite(color.name, purpose.value);
                    cards[color.index][purpose.index] = new Card(color, purpose,front);
                }
            }
        }

        public Card getCard(Color color, Purpose purpose) {
            return cards[color.index][purpose.index];
        }
    }

camera = new OrthographicCamera();
        camera.setToOrtho(false, 1280, 720); //** w/h ratio = 1.66 **//
        batch = new SpriteBatch();
        cardAtlas = new TextureAtlas("carddd.pack"); //** Load circles.pack and circles.png **//
        redZero = new TextureRegion(cardAtlas.findRegion("7G"))

;

0 个答案:

没有答案