I'm getting this error while working on Android Studio with libGDX.
Here's my code:
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.Animation;
public class MyGdxGame extends ApplicationAdapter {
private SpriteBatch batch;
private TextureAtlas shooterAtlas;
private Animation animation;
private float timePassed = 0 ;
@Override
public void create () {
batch = new SpriteBatch();
shooterAtlas = new TextureAtlas(Gdx.files.internal("shooter.atlas"));
animation = new Animation(1/30f,shooterAtlas.getRegions());
}
@Override
public void dispose() {
batch.dispose();
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
timePassed += Gdx.graphics.getDeltaTime();
batch.draw(animation.getKeyFrame(timePassed,true),300,500);
batch.end();
}
}
first i had this code:
import javafx.animation.animation
instead of:
import com.badlogic.gdx.graphics.g2d.Animation;
but it was giving me error on this:
animation = new Animation(1/30f,shooterAtlas.getRegions());
that: animation is an abstract cannot be instantiated But then I import this:
import com.badlogic.gdx.graphics.g2d.Animation;
and delete:
import javafx.animation.animation
because it was giving me error that you cant have both and resolving with alt+enter didn't worked also.
But on compilation it gives the error:
Warning:[options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\COMPUTER\Documents\new libgdx\core\src\com\mygdx\game\MyGdxGame.java 1 warning Error:Execution failed for task ':core:compileJava'.
Compilation failed; see the compiler error output for details. Information:BUILD FAILED Information:Total time: 1.526 secs Information:2 errors Information:1 warning Information:See complete output in console