Cheers as always Chrislo27,
At the moment I’m trying to implement a bad guy class, I’ve got the following as a start, but not sure if this is any good:
public interface IBadGuy {
void move(int x, int y);
void attack();
void decreaseHealth(int amount);
void spawn(int x, int y);
void load(String textureFile, int cols, int rows);
}
public abstract class BadGuy implements IBadGuy, Screen {
protected int x, y;
protected byte health;
protected Texture walkSheet;
protected Animation walkAnimation;
protected TextureRegion[] walkFrames;
protected TextureRegion currentFrame;
protected SpriteBatch batch;
@Override
public void load(String textureFile, int cols, int rows) {
// This is where you should set up your texture region, walkframes, walk animation and sprite batch
walkSheet = new Texture(Gdx.files.internal(textureFile));
TextureRegion[][] tmp = TextureRegion.split(walkSheet, walkSheet.getWidth()/cols, walkSheet.getHeight()/rows); // #10
walkFrames = new TextureRegion[cols * rows];
}
@Override
public void move(int x, int y) {
}
@Override
public void attack() {
}
@Override
public void decreaseHealth(int amount) {
}
@Override
public void spawn(int x, int y) {
}
@Override
public void show() {
}
@Override
public void render(float delta) {
System.out.println("Render in BadGuy");
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void hide() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
}
I would then have some bad guy manager class which would call the relevant interface methods…