私はlibgdxでゲームを作っています。私はその怪物(戦士、魔道師、..)の子クラスを持つスーパークラスのモンスターを持っています。私はこのMonsterクラス(実際には彼の子供)をplayScreenクラスにレンダリングしたいと思います。各クラスには独自のアニマトンとテクスチャ、ダメージ/ヘルス値があります。それ、どうやったら出来るの?どのクラスでレンダリングのための位置を定義するのですか、そのモンスターのアニメーションですか?子クラス、スーパークラス、またはplayScreenで私の現在のコードはここにある:libgdxの他のクラスのテクスチャをレンダリング
public class Monster {
public Animation monster;
public TextureAtlas atlas;
public int health;
public int damage;
public Monster(){
atlas = new TextureAtlas(Gdx.files.internal("mons1.txt"));
monster = new Animation(1/15f, atlas.getRegions());
}
子供クラス:
public class Mage extends Monster {
public Mage(int health,int damage, Animation animation){
super(health, damage, animation);
}
PlayScreenクラス:
public class PlayScreen implements Screen, InputProcessor {
private SpriteBatch batch;
public TextureAtlas atlas;
TextureRegion region;
private int height;
private Viewport viewport;
private Camera camera;
private int width;
private float elapsedTime = 0;
private Handler h;
private Stage stage;
private InputProcessor processor;
public PlayScreen(Handler h){
this.h = h;
batch = h.batch;
camera = h.camera;
viewport = h.viewport;
height = h.height;
width = h.width;
region = new TextureRegion();
stage = new Stage(viewport,batch);
stateTime = 0f;
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
batch.begin();
batch.end();
}