Following this tutorial: https://www.youtube.com/watch?v=1fJrhgc0RRw
I am getting "Gradle error: incompatible types: Object cannot be converted to TextureRegion"
at this line:
region = heroJump.getKeyFrame(stateTimer);
heroJump is declared as:
private Animation heroJump;
and that is imported up top as:
import com.badlogic.gdx.graphics.g2d.Animation;
In Android Studio the flyout box when you type heroJump.getKeyFrame() shows that Object is the return type of the function.
In the tutorial it shows a TexturedFrame.
I'm importing it the same as the tutorial.
I'm not sure why it doesn't see the return type as the same thing.
Even when I click the Animation class to view its docs it appears to come up with the proper return types.
What is not being done correctly so that AndroidStudio/Compiler knows the correct return type and will compile?
The method is declared in the API as
public T getKeyFrame(float stateTime)
And the class definition public class Animation<T>
.
You have a raw Animation
instance. The import isn't the problem. The declaration is.
For example, you'd want private Animation<TextureRegion> heroJump;
and you'd give that your Array<TextureRegion>