libGDX가 제공하는 상속 덕분에 쉽게 솔루션을 얻을 수 있습니다. Group
으로
는 (의사 코드)
public class Card extends Group {
final private static TextureAtlas ATLAS;
static {
ATLAS = AssetManager.get("game.pack", TextureAtlas.class);
}
public enum Type {
type1, type2, type3
}
private Type type;
private Image card;
private Label text;
private int hitPoints;
public Card(Type type) {
this.type = type;
card = new Image(ATLAS.get(type));
text = new Label("HP: " + hitPoints);
addActor(card);
addActor(text);
}
}
이것은 당신이 당신의 텍스처 아틀라스의 식별자와 관련된 카드 형식의 열거가 가정 ... 당신이 쉽게 할 수있는 배우이다; 텍스쳐 아틀라스를 사용하지 않는다면 그렇게하는 것이 좋습니다.
게임 로직 클래스에서 나는 Screen
클래스의 확장 일 것이라고 간단히 추측 할 수 있습니다. 등의 사용 사례에 경우 특정 배우 물론 위치의
private Card card;
@override
public void show() {
card = new Card(Card.Type.type1);
stage.addActor(card);
// This is an example - as the card and text reside within a group they can be moved as a sole entity relative to their parent
card.addAction(moveBy(100, 100, 2, Interpolation.Linear));
}
... 질문은 :
요청