libgdx - Java does not cast over to TextureRegion -


i trying draw multiple animations using hashmaps switch between them. part of code using.

    batch.draw((textureregion)hashmap.get(whichhashmap).get(c),x,y); 

when run code error @ line. error follows.

error:(162, 54) java: incompatible types: java.util.arraylist cannot converted com.badlogic.gdx.graphics.g2d.textureregion 

edit:

here decloration hash maps:

    arraylist<arraylist> whichhashmap;     arraylist<textureregion> animation1;     arraylist<textureregion> animation2;       animation1 = new arraylist<textureregion>();     animation2 = new arraylist<textureregion>();     whichhashmap.add(animation1);     whichhashmap.add(animation2);         region = new textureregion(powerpuff,1,55,41,44);     animation1.add(region);      region = new textureregion(powerpuff,47,54,41,45);     animation1.add(region);      region = new textureregion(powerpuff,1,55,41,44);     animation2.add(region);      region = new textureregion(powerpuff,47,54,41,45);     animation2.add(region); 

it sounds have hashmap of array lists, , each list contains keyframes animation. if so, doing wrong, treating entire arraylist single textureregion, rather grabbing single keyframe out of arraylist.

i.e;

//the map made this; map<object, arraylist<textureregion>> hashmap = new hashmap<...>();  //hashmap.get(whichhashmap) returns arraylist<textureregion> arraylist<textureregion> animation = hashmap.get(animationid);  //now draw correct frame batch.draw(animation.get(framenumber), x, y); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -