I understand that it is a framework; even more an open-source cross-platform game development library. I went to the libgdx homepage and followed the instruction on the video tutorial. After properly setting up my project I was able to run the default my-gdx-game project on the multiple supported platforms. Great, fine and dandy...now what?
I have been scouring the forums, wikis, javadocs, and many many more sites looking for decent straightforward how-to's. Unfortunately I couldn't find any, most of the help out there assumes you have some basic knowledge of this library.
I feel like the video tutorial showed me how to set up the project correctly, effectively getting my feet wet, then just assumed I know how to swim, and left me 300 miles out into the sea or something. I'm having trouble digesting the library, because I only started using it yesterday, so I'm a complete newcomer when it comes to libgdx.
I want to move my existing projects over to libgdx, but I'm use to BufferedImages, JFrames and things like that. Any help from the experienced veterans would be nice.
By the way I posted my core project below, so you guys can walk me through what is exactly going on here...
<code>
package com.me.mygdxgame;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
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 MyGdxGame 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(GL20.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() {
}
}
</code>