I am learning to program with the LibGDX library according to one tutorial, but the tutorial is made on an older version of LibGDX. Most of it was the same as my version, I made some adjustments, but I don't know much about this one. I have an Animation
and a SpriteBatch
declared:
private Animation standLeftAnime,standRightAnime;
private SpriteBatch batcher;
And this is what I'm trying to do:
if(chicken.getStandingState()== Chicken.StandingState.STANDLEFT)
batcher.draw(standLeftAnime.getKeyFrame(runTime),chicken.getPositionX(),chicken.getPositionY(),chicken.getWidth(),chicken.getHeight());
else if(chicken.getStandingState()== Chicken.StandingState.STANDRIGHT)
batcher.draw(standRightAnime.getKeyFrame(runTime),chicken.getPositionX(),chicken.getPositionY(),chicken.getWidth(),chicken.getHeight());
But it throws an error:
The method draw(Texture, float, float, float, float) in the type SpriteBatch is not applicable for the arguments (Object, float, float, float, float)
How can I solve this?
The Animation
class uses a generic type parameter. By default Object
will be used if you don't define one (that's why the error message says "not applicable for the arguments (Object, ...)").
In your case this means you have to change the first code snippet that you posted to:
private Animation<TextureRegion> standLeftAnime,standRightAnime;
private SpriteBatch batcher;
Maybe you also need to change the code that initializes the animations.