不幸的是(app)已经停止了

时间:2014-11-21 16:12:10

标签: java android eclipse libgdx

我在eclipse中使用libgdx并且对游戏开发很新。我遵循一些基本的教程,所以我不知道我的错误是什么。有人能帮我吗? Valkyrie是该项目的名称。 这是代码:

武神核: Valkyrie.java:

package com.valkyrie.game;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.valkyrie.game.screens.Play;

public class Valkyrie extends Game {
SpriteBatch batch;
Texture img;

@Override
public void create () {
    setScreen(new Play());
}
public void dispose()
{
    super.dispose();
}

@Override
public void render () {
    super.render();
}
public void resize(int width, int height)
{
    super.resize(width, height);
}
public void pause()
{
    super.pause();
}
public void resume()
{
    super.resume();
}
}

以及Play.java类

package com.valkyrie.game.screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;

public class Play implements Screen {
private TiledMap map;
private OrthogonalTiledMapRenderer renderer;
private OrthographicCamera camera;;

@Override
public void render(float delta) {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    renderer.setView(camera);
    renderer.render();

}

@Override
public void resize(int width, int height) {
    camera.viewportWidth = width;
    camera.viewportHeight = height;
    camera.update();

}

@Override
public void show() {

    map = new TmxMapLoader().load("forest1.tmx");
    renderer = new OrthogonalTiledMapRenderer(map);
    camera = new OrthographicCamera();

}

@Override
public void hide() {
    dispose();

}

@Override
public void pause() {
    // TODO Auto-generated method stub

}

@Override
public void resume() {
    // TODO Auto-generated method stub

}

@Override
public void dispose() {
    map.dispose();
    renderer.dispose();

}

}

Stacktrace控制台:

 11-21 16:26:14.879: D/dalvikvm(1002): Trying to load lib /data/data/com.valkyrie.game.android/lib/libgdx.so 0xa6adcf20
11-21 16:26:14.887: D/dalvikvm(1002): Added shared lib /data/data/com.valkyrie.game.android/lib/libgdx.so 0xa6adcf20
11-21 16:26:14.887: D/dalvikvm(1002): No JNI_OnLoad found in /data/data/com.valkyrie.game.android/lib/libgdx.so 0xa6adcf20, skipping init
11-21 16:26:14.891: D/libEGL(1002): loaded /system/lib/egl/libEGL_genymotion.so
11-21 16:26:14.895: D/(1002): HostConnection::get() New Host Connection established 0xb811cf60, tid 1002
11-21 16:26:14.903: D/libEGL(1002): loaded /system/lib/egl/libGLESv1_CM_genymotion.so
11-21 16:26:14.903: D/libEGL(1002): loaded /system/lib/egl/libGLESv2_genymotion.so
11-21 16:26:14.915: I/AndroidInput(1002): sensor listener setup
11-21 16:26:15.003: W/EGL_genymotion(1002): eglSurfaceAttrib not implemented
11-21 16:26:15.007: D/OpenGLRenderer(1002): Enabling debug mode 0
11-21 16:26:15.023: D/(1002): HostConnection::get() New Host Connection established 0xb80e4fc0, tid 1015
11-21 16:26:15.027: W/GL2JNIView(1002): creating OpenGL ES 2.0 context
11-21 16:26:15.095: D/dalvikvm(1002): Trying to load lib /data/data/com.valkyrie.game.android/lib/libgdx.so 0xa6adcf20
11-21 16:26:15.095: D/dalvikvm(1002): Shared lib '/data/data/com.valkyrie.game.android/lib/libgdx.so' already loaded in same CL 0xa6adcf20
11-21 16:26:15.095: I/GL2(1002): all initialized 2
11-21 16:26:15.095: I/AndroidGraphics(1002): OGL renderer: Android Emulator OpenGL ES Translator (GeForce GT 750M/PCIe/SSE2)
11-21 16:26:15.095: I/AndroidGraphics(1002): OGL vendor: Google (NVIDIA Corporation)
11-21 16:26:15.095: I/AndroidGraphics(1002): OGL version: OpenGL ES 2.0 (4.4.0 NVIDIA 344.65)
11-21 16:26:15.095: I/AndroidGraphics(1002): OGL extensions: GL_EXT_debug_marker GL_OES_EGL_image GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float 
11-21 16:26:15.095: E/EGL_genymotion(1002): [getAttribValue] Bad attribute idx
11-21 16:26:15.095: E/EGL_genymotion(1002): tid 1015: eglGetConfigAttrib(575): error 0x3004 (EGL_BAD_ATTRIBUTE)
11-21 16:26:15.095: E/EGL_genymotion(1002): [getAttribValue] Bad attribute idx
11-21 16:26:15.095: E/EGL_genymotion(1002): tid 1015: eglGetConfigAttrib(575): error 0x3004 (EGL_BAD_ATTRIBUTE)
11-21 16:26:15.095: I/AndroidGraphics(1002): framebuffer: (5, 6, 5, 0)
11-21 16:26:15.095: I/AndroidGraphics(1002): depthbuffer: (24)
11-21 16:26:15.095: I/AndroidGraphics(1002): stencilbuffer: (0)
11-21 16:26:15.095: I/AndroidGraphics(1002): samples: (0)
11-21 16:26:15.095: I/AndroidGraphics(1002): coverage sampling: (false)
11-21 16:26:15.095: I/AndroidGraphics(1002): Managed meshes/app: { }
11-21 16:26:15.099: I/AndroidGraphics(1002): Managed textures/app: { }
11-21 16:26:15.099: I/AndroidGraphics(1002): Managed shaders/app: { }
11-21 16:26:15.099: I/AndroidGraphics(1002): Managed buffers/app: { }
11-21 16:26:15.119: W/dalvikvm(1002): threadid=10: thread exiting with uncaught exception (group=0xa630b288)
11-21 16:26:15.119: E/AndroidRuntime(1002): FATAL EXCEPTION: GLThread 89
11-21 16:26:15.119: E/AndroidRuntime(1002): com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: map for game/pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:96)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:119)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:104)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.valkyrie.game.screens.Play.show(Play.java:36)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.Game.setScreen(Game.java:61)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.valkyrie.game.Valkyrie.create(Valkyrie.java:18)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:237)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
11-21 16:26:15.119: E/AndroidRuntime(1002): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: map for game/pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png (Internal)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
11-21 16:26:15.119: E/AndroidRuntime(1002):     ... 13 more
11-21 16:26:15.119: E/AndroidRuntime(1002): Caused by: java.io.FileNotFoundException: map for game/pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png
11-21 16:26:15.119: E/AndroidRuntime(1002):     at android.content.res.AssetManager.openAsset(Native Method)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at android.content.res.AssetManager.open(AssetManager.java:315)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at android.content.res.AssetManager.open(AssetManager.java:289)
11-21 16:26:15.119: E/AndroidRuntime(1002):     at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:75)
11-21 16:26:15.119: E/AndroidRuntime(1002):     ... 15 more
11-21 16:26:15.171: I/AndroidInput(1002): sensor listener tear down
11-21 16:26:15.171: I/AndroidGraphics(1002): Managed meshes/app: { }
11-21 16:26:15.171: I/AndroidGraphics(1002): Managed textures/app: { }
11-21 16:26:15.171: I/AndroidGraphics(1002): Managed shaders/app: { }
11-21 16:26:15.171: I/AndroidGraphics(1002): Managed buffers/app: { }

当我想在Android上运行它时,我应该在Valkyrie-android上运行吗?但每次我跑它,它总是停止,我不知道。

2 个答案:

答案 0 :(得分:-1)

显然缺少此文件: 的游戏/ pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png

读取行错误: com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件:map for game / pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png

答案 1 :(得分:-1)

如果唯一被加载到项目中的东西,你在课程中看到的内容,我认为你可以查看tmx文件。

示例tmx文件:

 <?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="27" height="19" tilewidth="32"    tileheight="32">
 <tileset firstgid="1" name="MoldeTileSet" tilewidth="32" tileheight="32">
  <image source="../Path/PathTileSet.png" width="1024" height="1024"/>
  <tile id="172">

看看这一行:

<image source="../Path/PathTileSet.png" width="1024" height="1024"/>

如果显示在堆栈上的名称,请检查您的android项目的相应目录中是否有该文件并开始自定义不匹配,我希望能够解释清楚

示例:

<image source="game/pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png" width="1024" height="1024"/>

这只是一个想法,我可以认为这可能是你所展示的错误

新:

如果您已复制到同一文件夹,文件tmx,tmx文件并打开该行:

<image source="game/pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png" width="1024" height="1024"/>

文件出现并修改它只留下示例nombre.png

<image source="pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png" width="1024" height="1024"/>

进行更改时刷新目录,或重新启动IDE