LibGDX getKeyFrame表示返回对象而不是TextureRegion/frame

Chr*_*ine 1 java android libgdx

遵循本教程:https://www.youtube.com/watch?v = 1fJrhgc0RRw

我收到"Gradle错误:不兼容的类型:对象无法转换为TextureRegion"

在这一行:

region = heroJump.getKeyFrame(stateTimer);

heroJump声明为:

private Animation heroJump;
Run Code Online (Sandbox Code Playgroud)

并且导入的最高位为:

import com.badlogic.gdx.graphics.g2d.Animation;
Run Code Online (Sandbox Code Playgroud)

在Android Studio中,当您键入heroJump.getKeyFrame()时,弹出框显示Object是函数的返回类型.
在教程中,它显示了TexturedFrame.
我正在导入它与教程相同.
我不确定为什么它没有看到返回类型是同一件事.
即使我单击Animation类来查看其文档,它似乎也会提供正确的返回类型.

什么没有正确完成,以便AndroidStudio/Compiler知道正确的返回类型并将编译?

cri*_*007 9

该方法在API中声明为

public T getKeyFrame(float stateTime)
Run Code Online (Sandbox Code Playgroud)

和班级定义public class Animation<T>.

你有一个原始Animation实例.导入不是问题.声明是.

例如,你想要的private Animation<TextureRegion> heroJump;,你会给你的Array<TextureRegion>