错误:(11,24)错误:包javafx.animation不存在。(安卓工作室、Libgdx、Javafx)

错误:(11,24)错误:包javafx.animation不存在。(安卓工作室、Libgdx、Javafx),java,android,animation,javafx,libgdx,Java,Android,Animation,Javafx,Libgdx,我正在尝试在Android Studio中使用LibGDX创建一个太空射击游戏。 在我尝试使用javafx.animation.animation类创建动画之前,其他一切都正常工作。在编译代码时,我得到以下3个错误和1个警告 Warning:[options] bootstrap class path not set in conjunction with -source 1.6 Error:(11, 24) error: package javafx.animation does not e

我正在尝试在Android Studio中使用LibGDX创建一个太空射击游戏。 在我尝试使用javafx.animation.animation类创建动画之前,其他一切都正常工作。在编译代码时,我得到以下3个错误和1个警告

Warning:[options] bootstrap class path not set in conjunction with -source 1.6

Error:(11, 24) error: package javafx.animation does not exist

Error:(22, 13) error: cannot find symbol class Animation

Error:(44, 26) error: cannot find symbol class Animation
我已经检查了我的android studio是否有javafx插件

我的代码中有两个类Shootergame.javaAnimatedSprite.java

问题在于AnimatedSprite.java类,该类的代码如下

    package com.ahmed.nullapointershooter;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;



import javafx.animation.Animation;


/**
 * Created by Hafeez ur Rehman on 8/30/2015.
 **/
public class AnimatedSprite {
    private static final int FRAMES_COL = 2;
    private static final int FRAMES_ROW = 2;

    private Sprite sprite;
    private Animation animation;
    private TextureRegion[] frames;
    private TextureRegion currentFrame;

    private float stateTime;

    public AnimatedSprite(Sprite sprite) {
        this.sprite = sprite;
        Texture texture = sprite.getTexture();
        TextureRegion[][] temp = TextureRegion.split(texture, texture.getWidth() / FRAMES_COL,
                texture.getHeight() / FRAMES_ROW);
        frames = new TextureRegion[FRAMES_COL * FRAMES_ROW];
        int index = 0;
        for (int i = 0; i < FRAMES_ROW; i++) {
            for (int j = 0; j < FRAMES_COL; j++) {
                frames[index++] = temp[i][j];
            }
        }


        /**
         * THE PROBLEM LIES HERE . I WANT TO DO THIS ----
         *                                           
         */

        //animation = new Animation(0.1f, frames);
         animation = new Animation() {
            @Override
            public void impl_playTo(long l, long l1) {

            }

            @Override
            public void impl_jumpTo(long l, long l1) {

            }
        };
        stateTime = 0f;
    }

    public void setPosition(float x, float y){
        float widthOffset = sprite.getWidth() / FRAMES_COL;
        sprite.setPosition(x - widthOffset / 2, y);
    }


    public void draw(SpriteBatch spriteBatch){
        stateTime += Gdx.graphics.getDeltaTime();
        //currentFrame = animation.getKeyFrame(stateTime, true);

        spriteBatch.draw(currentFrame, sprite.getX(), sprite.getY());
    }


}

我的问题解决了。我使用了Javafx来导入动画类,这在一开始是错误的,因为android中没有Javafx包。相反,我不得不进口
导入com.badlogic.gdx.graphics.g2d.Animation现在开始工作了

androidI am上没有javafx包,它使用Libgdx为多平台(android、Java(桌面))创建游戏。我应该使用什么来代替javafx来执行动画?我只使用了一点javafx,但没有使用动画,不确定您需要什么,我认为您应该开始一个新的问题,具体询问您需要什么动画以及使用什么android类。您是对的。我的问题解决了。我使用Javafx导入动画类,这在一开始是错误的。相反,我必须导入com.badlogic.gdx.graphics.g2d.Animation;现在它工作了!非常感谢你
package com.ahmed.nullapointershooter;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class ShooterGame extends ApplicationAdapter {
    private OrthographicCamera camera;
    private SpriteBatch batch;
    private Texture background;
    private AnimatedSprite spaceshipAnimated;


    @Override
    public void create() {
        //Texture.setEnforcePotImages(false);

        camera = new OrthographicCamera();
        camera.setToOrtho(false, 800, 480);

        batch = new SpriteBatch();

        background = new Texture(Gdx.files.internal("NullapointerBackground.png"));
        Texture spaceshipTexture = new Texture(Gdx.files.internal("Spaceshipcanvas.png"));
        Sprite spaceshipSprite = new Sprite(spaceshipTexture);
        spaceshipAnimated = new AnimatedSprite(spaceshipSprite);
        spaceshipAnimated.setPosition(800 / 2, 0);

    }


    @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.setProjectionMatrix(camera.combined);
        batch.begin();
        batch.draw(background, 0, 0);
        spaceshipAnimated.draw(batch);
        batch.end();
    }

    @Override
    public void resize(int width, int height) {

    }
}