1

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

manfcas
  • 1,933
  • 7
  • 28
  • 47

1 Answers1

0

The last error is because you are compiling your code with the previous jdk version and you have a newer one try to set source and target both to the jdk version you currently have.

Wijdan
  • 203
  • 3
  • 12
  • also i solved this error by adding import com.badlogic.gdx.graphics.g2d.Animation; but it gives a error in the last which i described – Puneet Sharma Jan 25 '16 at 11:00