I’m making game using Kotlin language + LibGDX library.
As official documentation says “ operation stands for calls to member functions get() and set().”
But, when i try to run this line of code:
body.userData = animations[state[e].currentState]!!.keyFrames[frame]
I get this error:
Exception in thread "LWJGL Application" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lcom.badlogic.gdx.graphics.g2d.TextureRegion;
However when i change  to get():
body.userData = animations[state[e].currentState]!!.keyFrames.get(frame)
Everything gets ok.
PS: “frame” is angle, converted to Int.
I changed my code little bit
val animation: Animation = anim[e].animations[state[e].currentState]!!
val tex = animation.keyFrames[frame] // Get exception on this line anyway
body[e].body.userData = tex
“e” is entity refrence from Ashley. “body”, “anim”, and “state” are Ashley component mappers.
For those who doesn’t know what LibGDX is here is Animation class
keyFrames here is just a Java Array.
I noticed that problem occurs only when i use this constructor:
Animation(float frameDuration, Array<? extends T> keyFrames)