libgdx loading textures fails [duplicate]
- by Chris
This question already has an answer here:
    
        
            Why do I get this file loading exception when trying to draw sprites with libgdx?
                
                        
                            4 answers
                        
                
        
    
            I'm trying to load my texture with
playerTex = new Texture(Gdx.files.internal("player.jpg"));
player.jpg is located under my-gdx-game-android/assets/data/player.jpg
I get an exception like this:
Full Code:
@Override
public void create() {      
    camera = new OrthographicCamera();
    camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());        
    batch = new SpriteBatch();
    FileHandle file = Gdx.files.internal("player.jpg");
    playerTex = new Texture(file);
    player = new Rectangle();
    player.x = 800-20;
    player.y = 250;
    player.width = 20;
    player.height = 80;
}
@Override
public void dispose() {
    // dispose of all the native resources
    playerTex.dispose();
    batch.dispose();
}
@Override
public void render() {      
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(playerTex, player.x, player.y);
    batch.end();
    if(Gdx.input.isKeyPressed(Keys.DOWN)) player.y -= 50 * Gdx.graphics.getDeltaTime();
    if(Gdx.input.isKeyPressed(Keys.UP)) player.y += 50 * Gdx.graphics.getDeltaTime();
}