Android 当使用按钮时,我的程序关闭,libgdx

Android 当使用按钮时,我的程序关闭,libgdx,android,libgdx,Android,Libgdx,我的按钮遇到了问题。我的代码如下 public class rarsterinco implements ApplicationListener { Texture background; Texture background2; Texture background3; Vector2 backgroundmove; Vector2 backgroundmove2; SpriteBatch batch; Rectangle bounds;

我的按钮遇到了问题。我的代码如下

public class rarsterinco implements ApplicationListener {
    Texture background;
    Texture background2;
    Texture background3;
    Vector2 backgroundmove;
    Vector2 backgroundmove2;
    SpriteBatch batch;
    Rectangle bounds;
    CharSequence line = "got touched."; // = myScore;
    Rectangle bounds2;
    boolean check;
    boolean collision;
    int beginning;
    CharSequence headup = "got touched";
    Vector2 pos;
    Vector2 position;
    Vector2 size;
    Vector2 size2;
    BitmapFont font;
    Texture mysteryCloud;
    Texture mario;

    Texture water;
    Vector2 watermove;
    Vector2 watersize;
     Stage stage;
     TextureAtlas buttonAtlas;
        TextButtonStyle buttonStyle;
        TextButton button;
        Skin skin;


    @Override
    public void create() {
        BitmapFont font = new BitmapFont();
        skin = new Skin();
        buttonAtlas = new TextureAtlas("buttons/pause.pack");
        skin.addRegions(buttonAtlas);

        buttonStyle = new TextButtonStyle();
        buttonStyle.up = skin.getDrawable("imgres");
        buttonStyle.over = skin.getDrawable("imgres");
        buttonStyle.down = skin.getDrawable("imgres");


        button = new TextButton("", buttonStyle);


        stage.addActor(button);


        mysteryCloud = new Texture(Gdx.files.internal("data/mysteryCloud.jpg"));
        batch = new SpriteBatch();
        mario = new Texture(Gdx.files.internal("data/mario.jpg"));
        background = new Texture(Gdx.files.internal("data/background1.jpg"));
        background2 =  new Texture(Gdx.files.internal("data/background2.jpg"));
        background3 =  new Texture(Gdx.files.internal("data/background3.jpg"));
        position = new Vector2();
        pos = new Vector2();
        backgroundmove = new Vector2();
        backgroundmove2 = new Vector2();
        size2 = new Vector2(mario.getWidth() ,mario.getHeight() );
        //size2.y = trash.getHeight();
        //size2.x = trash.getWidth();
        size = new Vector2(mysteryCloud.getWidth() ,mysteryCloud.getHeight());
        bounds= new Rectangle(pos.x, pos.y, size.x, size.y);
        bounds2= new Rectangle(position.x, position.y, 32, 32);

            }

    @Override
    public void dispose() {
    //font.dispose();

    }
    public void update(){

        bounds.set(pos.x, pos.y, 32, 32);
        bounds2.set(position.x, position.y, size2.x, size2.y);
        position.x = position.x + 5* Gdx.input.getAccelerometerY();


        //float pos1=Gdx.input.getAccelerometerY();

        //position.x = position.x - 5*pos1;

        //float pos2=Gdx.input.getAccelerometerY();

        //position.y = position.y - 5*pos2;
    }
    @Override
    public void render() {  

        beginning = beginning+ 1;
        if(beginning == 1){
            backgroundmove.x = Gdx.graphics.getWidth();
        }
        position.y = position.y -10;
        if(position.x<0){
            Gdx.input.vibrate(250);
        }
        if(position.x>Gdx.graphics.getWidth()){
            Gdx.input.vibrate(250);
        }   
        //if(position.y<0){
            //Gdx.input.vibrate(250);
        //}
        if(position.y>Gdx.graphics.getHeight()){
            Gdx.input.vibrate(250);
        }   
        if(bounds.overlaps(bounds2)){
            collision=true; 
            }else{
                collision= false;
            }

        if(position.x<0){
            position.x= position.x+80;
        }
        if(position.x>Gdx.graphics.getWidth() - mario.getWidth()){
            position.x= position.x-80;
        }

        if(Gdx.input.isTouched()){
            position.y = position.y + 30;
        }

        if(position.y<0){
            position.y= position.y+80;
        }
        if(position.y>Gdx.graphics.getWidth() +mario.getHeight()){
            position.y= position.y-80;
        }
        pos.x = pos.x - 10;
        if(pos.x <0 && collision == false){
            pos.x = Gdx.graphics.getWidth();
            Random randomGenerator = new Random();
            pos.y = randomGenerator.nextInt(Gdx.graphics.getHeight()-30);
        }

        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        if(Gdx.input.getAccelerometerX() == 10){

        }
        if(collision){
            pos.x = Gdx.graphics.getWidth();
            Random randomGenerator = new Random();
            pos.y = randomGenerator.nextInt(Gdx.graphics.getHeight()-30);
        }
        backgroundmove.x = backgroundmove.x - 10;
        backgroundmove2.x = backgroundmove2.x - 10;
        if(backgroundmove.x <-Gdx.graphics.getWidth()){
            backgroundmove.x = Gdx.graphics.getWidth();
        }
        if(backgroundmove2.x <-Gdx.graphics.getWidth()){
            backgroundmove2.x = Gdx.graphics.getWidth();
        }
        update();
        batch.begin();



//      if(!collision){
//          batch.draw(mysteryCloud, pos.x, pos.y, 64, 64);
//      }           

//      batch.draw(mysteryCloud, pos.x, pos.y, 64, 64);
//              if(collision){
//                  mysteryCloud.dispose(); 
//              }
//              if(pos.x<0 && collision == true){
//                  batch.draw(mysteryCloud, pos.x, pos.y, 64, 64);
//              }
//          

        //batch.draw(background3, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());         
        //batch.draw(background, backgroundmove.x, backgroundmove.y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());    
        //batch.draw(background2, backgroundmove2.x, backgroundmove2.y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 

        batch.draw(mario, position.x,position.y);
        batch.draw(mysteryCloud, pos.x, pos.y, 64, 64);
        font.setScale(4);
        font.setColor(0.0f, 1.0f, 1.0f,1.0f);
        stage.draw();  
        batch.end();

    }


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

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }
}
,

线程“LWJGL应用程序”com.badlogic.gdx.utils.GdxRuntimeException中的异常:com.badlogic.gdx.scenes.scene2d.ui.Skin.getDrawable(Skin.java:291)com.me.rarsterinco.rarsterinco.create(rarsterinco.java:64)中未注册名称为imgres的Drawable、NinePatch、TextureRegion、Texture或Sprite在com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:‌​136)在com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114‌​)
线程“LWJGL应用程序”java.lang.IllegalArgumentException:com.badlogic.gdx.scene2d.ui.Label.setStyle(Label.java:77)com.badlogic.gdx.scene2d.ui.Label.(Label.java:71)com.badlogic.gdx.scene2d.ui.TextButton.(TextButton.java:48)com.me.rarstinco.rarstinco.create(rarsterinco.java:69)位于com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:‌​136)在com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114‌​)

请在线程“LWJGL Application”com.badlogic.gdx.utils.GdxRuntimeException:com.me.rarsterinco.rarsterinco.create上没有可绘制、NinePatch、TextureRegion、Texture或Sprite注册名为imgres的LogcateException异常堆栈跟踪(rarsterinco.java:64)在com.badlogic.gdx.backends.lwjgl.lwjglaplication.mainLoop(lwjglaplication.java:136)在com.badlogic.gdx.backends.lwjgl.lwjglaplication$1.run(lwjglaplication.java:114)上,这是线程“LwjglApplication”中的异常java.lang.IllegalArgumentException:com.badlogic.gdx.scenes.scene2d.ui.Label.setStyle(Label.java:77)com.badlogic.gdx.scene2d.ui.Label.(Label.java:71)com.badlogic.gdx.scene2d.ui.TextButton.(TextButton.java:48)com.me.rarsterinco.rarsterinco.rarsterinco.create(rarsterinco.java:69)在com.badlogic.gdx.backends.lwjgl.lwjglaplication.mainLoop(lwjglaplication.java:136)在com.badlogic.gdx.backends.lwjgl.lwjglaplication$1.run(lwjglaplication.java:114)在纹理图集中包含了
imgres
吗?对不起,你是什么意思?
TextureAtlas buttonAtlas;
TextButtonStyle buttonStyle;
TextButton button;
Skin skin;


@Override
public void create() {
    BitmapFont font = new BitmapFont();
    skin = new Skin();
    buttonAtlas = new TextureAtlas("buttons/pause.pack");
    skin.addRegions(buttonAtlas);

    buttonStyle = new TextButtonStyle();
    buttonStyle.up = skin.getDrawable("imgres");
    buttonStyle.over = skin.getDrawable("imgres");
    buttonStyle.down = skin.getDrawable("imgres");


    button = new TextButton("", buttonStyle);


    stage.addActor(button);
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: imgres at com.badlogic.gdx.scenes.scene2d.ui.Skin.getDrawable(Skin.java:291) at com.me.rarsterinco.rarsterinco.create(rarsterinco.java:64) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:‌​136) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114‌​)
Exception in thread "LWJGL Application" java.lang.IllegalArgumentException: Missing LabelStyle font. at com.badlogic.gdx.scenes.scene2d.ui.Label.setStyle(Label.java:77) at com.badlogic.gdx.scenes.scene2d.ui.Label.<init>(Label.java:71) at com.badlogic.gdx.scenes.scene2d.ui.TextButton.<init>(TextButton.java:48) at com.me.rarsterinco.rarsterinco.create(rarsterinco.java:69) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:‌​136) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114‌​)