The source code for Beginning Java Game Development with LibGDX is at the URL shown.
I gave myself two gifts for Christmas: A set of new bathroom rugs, and a few guilt-free days to learn the LibGDX game framework so I can eventually rewrite my football game. (Usually I think, “You need to finish writing XYZ,” so “a few guilt-free days” means not having those thoughts, or having them but ignoring them.)
If you ever need to create a
Dialog in LibGDX, I can confirm that this example code works:
I just started working with LibGDX, so I don’t know if there’s a better way to create a LibGDX Scene2d
ImageButton, but I can confirm that this approach works:
Texture hikeTexture = new Texture(Gdx.files.internal("hike_btn.jpg")); Texture hikeTexturePressed = new Texture(Gdx.files.internal("hike_btn_pressed.jpg")); hikeButton = new ImageButton( new TextureRegionDrawable(new TextureRegion(hikeTexture)), new TextureRegionDrawable(new TextureRegion(hikeTexturePressed)) ); hikeButton.setPosition(60, 300); //hikeButton is an ImageButton stage.addActor(hikeButton);
I currently use this code in the
show() method of a class that implements
Screen, and it works as desired.
This is a good resource for LibGDX programming on Android.
I don’t know much about LibGDX yet, but one thing I’ve learned is that if you get the LibGDX error message, “Your Android SDK path doesn’t contain an SDK,” it’s because the LibGDX setup tool doesn’t work automatically with the Android SDK tools that you download from the Android website, at least not the default tools. (That directory may work after you do some configuration with the sdkmanager, dunno.)