# How to insert animation into table?

I'm having trouble inserting animation into my libGDX table cell. I have a class which holds 2 tables, one on the left and one on the right. First table is for labels/buttons/other stuff. Second table is for animation, which should change if user clicks a button.

I've created Animation class which holds up different animations. The problem is that when I try to add an animation class into the table cell, I get an error because my Animation does not extend nor implement Actor class, thus I can't insert it into the cell. What should I do? How do you insert class of type animation into table cell?

You probably want to extend the Image class yourself and implement the Act method to update the animation state time.

public class Animation extends Image{
private float stateTime = 0;
private Animation<TextureRegion> animation;

public AnimatedActor(Animation<TextureRegion> anim) {
super(animation.getKeyFrame(0));
animation = anim;
}

@Override
public void act(float delta){
((TextureRegionDrawable)getDrawable()).setRegion(animation.getKeyFrame(stateTime+=delta, true));
super.act(delta);
}
}


If you want more control over the animation you could even oerride the draw method and draw it yourself.

@Override
draw(Batch batch, float parentAlpha){