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
        // The bird needs transparency.

        // Draw bird at its coordinates. Retrieve the Animation object from
        // AssetLoader
        // Pass in the runTime variable to get the current frame.
                x, y, width, height);

        // End SpriteBatch

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);

The class where i call AssetLoader.load()

public class ZBGame extends Game {
    public void create() {
        /* Other stuff */
  • \$\begingroup\$ Why are there two instances of this question? At any rate, is AssetLoader.load() ever called? \$\endgroup\$
    – JonBee
    Commented Dec 28, 2016 at 16:36
  • \$\begingroup\$ The first instance was before i signed up to the website, sorry. and yes the asseloader.load function is called from my Create() function of the game, i added it in the question. \$\endgroup\$
    – aysam
    Commented Dec 28, 2016 at 16:58

2 Answers 2


Try changing your last batcher draw in GameRenderer class to

                bird.getX(), bird.getY(), bird.getWidth(), bird.getHeight());
  • \$\begingroup\$ that was my first attempt to fix it, it didn't work. \$\endgroup\$
    – aysam
    Commented Jan 13, 2017 at 0:20

The Animation class is generic (see docs) - meaning you should supply the type of object being animated which in your case would be TextureRegion since the keyframes are of type TextureRegion.

This means your code now becomes:

/* Declaration. */
public static Animation<TextureRegion> birdAnimation;

/* In your load() method. */
birdAnimation = new Animation<TextureRegion>(0.06f, birds);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .