Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Need help, cant get this thing working. Eclipse libgdx.
Need help, cant get this thing working. Eclipse libgdx. [message #1734033] Fri, 03 June 2016 08:17 Go to next message
Tom Stral is currently offline Tom StralFriend
Messages: 2
Registered: June 2016
Junior Member
I was following this tutorial on youtube and i got stuck. well here is my code;
package com.me.Shitgame;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
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.badlogic.gdx.graphics.g2d.TextureRegion;

public class ShitGame implements ApplicationListener {
private OrthographicCamera camera;
private SpriteBatch batch;
private Texture texture;
private Sprite sprite;

@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();

camera = new OrthographicCamera(1, h/w);
batch = new SpriteBatch();

texture = new Texture(Gdx.files.internal("data/libgdx.png"));
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);

sprite = new Sprite(region);
sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2);
}

@Override
public void dispose() {
batch.dispose();
texture.dispose();
}

@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

batch.setProjectionMatrix(camera.combined);
batch.begin();
sprite.draw(batch);
batch.end();
}

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

@Override
public void pause() {
}

@Override
public void resume() {
}
}


And here is the error;
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/libgdx.png
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/libgdx.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:175)
at com.badlogic.gdx.graphics.Texture.create(Texture.java:159)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122)
at com.me.Shitgame.ShitGame.create(ShitGame.java:27)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:127)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: data\libgdx.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:127)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:580)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:215)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 8 more
It keeps wanting to render data/libgdx.png but i dont tell it to render that image... please help im a newcomer to... well codeing in general.
Re: Need help, cant get this thing working. Eclipse libgdx. [message #1734078 is a reply to message #1734033] Fri, 03 June 2016 14:54 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member

You have this line:
texture = new Texture(Gdx.files.internal("data/libgdx.png"));

It *does* call for 'data/libgdx.png'.


--

Tauno Voipio
Re: Need help, cant get this thing working. Eclipse libgdx. [message #1734083 is a reply to message #1734078] Fri, 03 June 2016 15:40 Go to previous message
Tom Stral is currently offline Tom StralFriend
Messages: 2
Registered: June 2016
Junior Member
oh.... oh... OH i figured it out.... i used a wrong code as my main one... XD im a dumbass...
Previous Topic:Neon Update / Marketplace unable to connect
Next Topic:Reinstalled eclipse Kepler, now privilege missing
Goto Forum:
  


Current Time: Fri Apr 26 08:42:23 GMT 2024

Powered by FUDForum. Page generated in 0.09695 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top