I am having a problem with the last part of the GameRenderer
class. I call batcher.draw()
and receive this error:
The method draw(Texture, float, float, float, float) in the type SpriteBatch is not applicable for the arguments (Object, float, float, float, float)
This only happens when I try to draw animation; images work fine. How do I fix this?
This is my GameRenderer
class, which throws the error.
public class GameRenderer {
private SpriteBatch batcher = new SpriteBatch();
public void render(float runTime) {
// Begin SpriteBatch
batcher.begin();
// The bird needs transparency.
batcher.enableBlending();
// Draw bird at its coordinates. Retrieve the Animation object from
// AssetLoader
// Pass in the runTime variable to get the current frame.
batcher.draw(AssetLoader.birdAnimation.getKeyFrame(runTime),
x, y, width, height);
// End SpriteBatch
batcher.end();
}
}
Just in case, here is my AssetLoader
class:
public class AssetLoader {
public static Animation birdAnimation;
public static void load() {
Texture texture = new Texture(Gdx.files.internal("data/texture.png"));
texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
TextureRegion birdDown = new TextureRegion(texture, 136, 0, 17, 12);
birdDown.flip(false, true);
TextureRegion bird = new TextureRegion(texture, 153, 0, 17, 12);
bird.flip(false, true);
TextureRegion birdUp = new TextureRegion(texture, 170, 0, 17, 12);
birdUp.flip(false, true);
TextureRegion[] birds = { birdDown, bird, birdUp };
birdAnimation = new Animation(0.06f, birds);
birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
}
}
The class where i call AssetLoader.load()
public class ZBGame extends Game {
@Override
public void create() {
AssetLoader.load();
/* Other stuff */
}
}