# [libGDX] findet SplashScreen.png nicht



## Waterfront (19. Jul 2014)

Moin ich habe keine Erfahrung mit libGDX sondern bringe mir grad alles bei.

Ich möchte einfach nur den SplashScreen anzeigen lassen, mit der SplashScreen.png

Dabei kommt folgende Fehlermeldung:


```
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: assets/SplashScreen.png
	at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
	at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
	at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:88)
	at com.mygdx.Screens.SplashScreen.show(SplashScreen.java:42)
	at com.badlogic.gdx.Game.setScreen(Game.java:61)
	at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:16)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: assets\SplashScreen.png (Internal)
	at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
	at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
	at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
	... 11 more
```

in der SplashScreen.java steht:


```
package com.mygdx.Screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.mygdx.game.MyGdxGame;

public class SplashScreen implements Screen {

	Texture splashTexture;
	Sprite splashSprite;
	SpriteBatch batch;
	MyGdxGame game;
	

	
	public SplashScreen(MyGdxGame game) {
		this.game = game;
	}

	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(0,0,0,1);
		Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
		
		batch.begin();
		splashSprite.draw(batch);
		batch.end();
	}

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

	@Override
	public void show() {
		splashTexture = new Texture("assets/SplashScreen.png");
		splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		splashSprite = new Sprite(splashTexture);
		splashSprite.setOrigin(splashSprite.getWidth()/2, splashSprite.getHeight() / 2);
		splashSprite.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
		
		batch = new SpriteBatch();
		
	}

	@Override
	public void hide() {
		
	}

	@Override
	public void pause() {
		
	}

	@Override
	public void resume() {
		
	}

	@Override
	public void dispose() {
		
	}

}
```

MyGdxGame.java


Spoiler





```
package com.mygdx.game;

import com.badlogic.gdx.Game;
import com.mygdx.Screens.SplashScreen;


public class MyGdxGame extends Game  {

	public static final String TITLE ="Jobas Game";
	public static final String VERSION = " 0.0.0.01 pre-alpha";
	public static final int windowWidth = 800;
	public static final int windowHeight = windowWidth / 16 * 9;
	
	@Override
	public void create () {
		setScreen(new SplashScreen(this));
	}
	
	@Override
	public void dispose(){
		super.dispose();
	}
	
	@Override
	public void render(){
		super.render();
	}
	
	@Override
	public void resize (int width, int height){
		super.resize(width, height);
	}
	
	@Override
	public void pause(){
		super.pause();
	}
	
	@Override
	public void resume(){
		super.resume();
	}
		
	
}
```




DesktopLauncher.java:


Spoiler





```
package com.mygdx.game.desktop;

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.mygdx.game.MyGdxGame;

public class DesktopLauncher {
	public static void main (String[] arg) {
		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
		
		config.title = MyGdxGame.TITLE + MyGdxGame.VERSION;
		config.width = MyGdxGame.windowWidth;
		config.height = MyGdxGame.windowHeight;
		config.fullscreen = false;
		config.resizable = false;
		config.useGL30 = true;
		
		
		new LwjglApplication(new MyGdxGame(), config);
	}
}
```




P.S ich habe eben schnell geguckt ob der assets Ordner richtig verlinkt wurde, ja das ist er.

LG
Water


----------



## Androbin (19. Jul 2014)

Bist du dir auch 100%ig sicher, dass der Pfadangabe stimmt?
Da gibt es nämlich eine ganze Reihe von Fehlerquellen!


----------



## Topfpflanze (19. Jul 2014)

In der Rendermethode teilst du durch null, das ist eher ungünstig.


----------



## Androbin (19. Jul 2014)

Soweit ich weiß, kann man das "assets/" in libGDX weglassen; versuch's doch mal!


----------



## Waterfront (19. Jul 2014)

@Androbin:

Jap die Angabe "assets" habe ich weggelassen und prompt hat es geklappt   Danke :toll:

@Topfpflanze: 

Öhm ne?  ich seh da nix durch 0

Lg
Water:idea:


----------

