在构建应用程序时,在“ tex = animation.getKeyFrame(stateTime);”行中出现问题上有通知:不兼容的类型。找到:“ java.lang.Object”,必需:“ com.badlogic.gdx.graphics.g2d.TextureRegion”
Build.gradle
compileSdkVersion 29
gdxVersion = '1.9.10'
roboVMVersion = '1.9.10'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.3'
aiVersion = '1.6.0'
这是我在
上的代码@Override
public void draw(Batch batch, float parentAlpha) {
// frame of animation
if (animation != null)
tex = animation.getKeyFrame(stateTime);
// particle effect
if (effect != null) {
Vector2 point = localToStageCoordinates(new Vector2(2, 53));
effect.setPosition(point.x - Main.stage.getRoot().getX(), point.y - Main.stage.getRoot().getY());
effect.draw(batch, Gdx.graphics.getDeltaTime());
}
if (tex != null) {
// draw
Color color = getColor();
batch.setColor(color.r * brightness, color.g * brightness, color.b * brightness, color.a * parentAlpha);
batch.draw(tex, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX() * flipX, getScaleY()
* flipY, getRotation());
batch.setColor(color.r, color.g, color.b, 1);
}
}
任何人请帮助我