-6

I'm using libgdx in eclipse and im stil new to game development. im following some basic tutorials so i dont know what is my error. can someone help me? Valkyrie is the name of the project. here's the code:

Valkyrie-core: 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();
}
}

and for the class 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 Console:

 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: { }

when i want to run it on android, i should do it on Valkyrie-android right? but every time i run it, it always stops and i have no idea.

Daahrien
  • 10,190
  • 6
  • 39
  • 71
  • 3
    An app won't crash "silently" so please get the Stacktrace of the occurred exception and post it here (in the question and not in the comments). – Tom Nov 21 '14 at 16:16
  • @Tom there i just posted the whole stacktrace. i dont know how to resolve the problem – John Uchi Ilan Nov 21 '14 at 16:36
  • @Selvin still cant solve my problem. dont know how to debug with stacktrace – John Uchi Ilan Nov 21 '14 at 16:42
  • 1
    StackTrace says: "Couldn't load file: map for game/pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:140)". So have a look line 140 of Pixmap.java – Arthur Rey Nov 21 '14 at 16:43
  • 2
    i'm removing close vote since you provided logcat log ... but still it deserves -1 becuase exception is obvious and self explanatory – Selvin Nov 21 '14 at 16:44
  • @ArthurRey i do not know libgdx but problem is rather in forest1.tmx (xml?) there is a reference to this file(?) and the file does not exist in assets(?) ... (?) == just blind guess since i did not use libgdx – Selvin Nov 21 '14 at 16:48
  • I added a close-vote and a -1, @Selvin. I think it's deserved as the asker managed to copy and paste the logcat, but apparently forgot to read it. The close-vote is because I wouldn't expect the asker to read any answers, which might be longer than the logcat. – 323go Nov 21 '14 at 16:48
  • @323go problem is when you retract close vote you can not add it again(with different reason) – Selvin Nov 21 '14 at 16:49
  • I understand, @Selvin. I trust this question will either be closed or voluntarily removed before too long. – 323go Nov 21 '14 at 16:50
  • @Selvin i didnt forgot to place the tmx file in the asset and its tmx not xml because its a from tiled – John Uchi Ilan Nov 21 '14 at 16:55
  • 2
    @323go i read it. i just dont know how to solve it. you guys are so rude. i just said im new in game devt. geez – John Uchi Ilan Nov 21 '14 at 16:57
  • i meant there is no "pokemon" file in assets but it is referenced in tmx file ... you have fx: `` in tmx ... as i said i do not know libgdx but ... – Selvin Nov 21 '14 at 16:57

2 Answers2

-1

Apparently missing this file: game/pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png

read the line error: com.badlogic.gdx.utils.GdxRuntimeException: Could not load file: map for game / pokemon_tileset_from_public_tiles_by_chaoticcherrycake-d5xdb0y.png

Elvis Lima
  • 134
  • 5
-1

if the only thing that gets loaded into your project, what you see in the classes put, I think you can look at the tmx file.

example tmx file:

 <?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">

look at this line:

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

If the name shown on the stack, check that you have the file in the appropriate directory of your android project and start customizing mismatch appears and I hope to explain well

example:

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

It is just an idea, where I can think that might be the error, which you show

New:

if you have copied into the same folder, the file tmx, tmx file and opens the line:

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

where the file appears and modify it only leaves the example nombre.png

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

when you make changes refreshes the directory, or restart the IDE

Angel Angel
  • 19,670
  • 29
  • 79
  • 105
  • i think my problem is that i have two tileset(.png) which is i just placed in asset folder together with the tmx file. i used two png file to create one tmx. so do i need to delete one tileset? – John Uchi Ilan Nov 21 '14 at 17:01