Crap that did take a lot of cursing to add code snippets in Blogger. Anyway
Didn't hit the "any" coding key yet, just browsing through the project that LibGDX created, and now imported/opened by Android Studio. With my usual sceptism. I typically dislike these standard framework kinda things. And on top, I find Java messy by nature in terms of having 6-thousand different classes for even doing nothing (nothing = new Nothing() ), and having too many meaningless names. The Jelly core runs on Grapefruit 3 with Fat Bertha accelerated test-stubs, on top of Walrus balls. Any idea what I'm talking about? I don't.
The project folder looks like a small battlefield, having lots of directories and files that confuse me. But, where you should focus on for now, is the "core". That's your playground, all the other stuff is multi-platform mumbo jumbo, and of course the necessary LibGDX framework files itself. If you open core/.../.../ JunkThrower.java, you actually see a few lines that look like they may have something to do with your game.And you will quickly see the 3 stages as well here: "born", "live", "die". Or as the function names would say Create, Render, Dispose.
Got to admit... only 1 file and 3 functions to start with... And if you click "compile", it even works! Now that's why I call, a friendly introduction.
package com.mygdx.game;
import
com.badlogic.gdx.ApplicationAdapter;
import
com.badlogic.gdx.Gdx;
import
com.badlogic.gdx.graphics.GL20;
import
com.badlogic.gdx.graphics.Texture;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
@Override
public void dispose () {
batch.dispose();
img.dispose();
}
}
Weiterlesen...