Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.marsminer.game;
- import com.badlogic.gdx.ApplicationAdapter;
- import com.badlogic.gdx.Game;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.assets.AssetManager;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.Batch;
- import com.badlogic.gdx.graphics.g2d.BitmapFont;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.graphics.g2d.TextureAtlas;
- import com.badlogic.gdx.scenes.scene2d.Stage;
- import com.badlogic.gdx.scenes.scene2d.ui.Skin;
- import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
- import java.awt.Color;
- import sun.applet.Main;
- public class MarsMiner extends Game {
- Stage stage;
- TextButton button;
- TextButton.TextButtonStyle textButtonStyle;
- BitmapFont font;
- Skin skin;
- TextureAtlas textureAtlas;
- @Override
- public void create () {
- stage = new Stage();
- Gdx.input.setInputProcessor(stage);
- font = new BitmapFont();
- skin = new Skin();
- textureAtlas = new TextureAtlas(Gdx.files.internal("buttons/buttons.pack"));
- skin.addRegions(textureAtlas);
- textButtonStyle = new TextButton.TextButtonStyle();
- textButtonStyle.font = font;
- textButtonStyle.up = skin.getDrawable("up-button");
- textButtonStyle.down = skin.getDrawable("down-button");
- textButtonStyle.checked = skin.getDrawable("checked-button");
- button = new TextButton("Button1", textButtonStyle);
- stage.addActor(button);
- }
- @Override
- public void render () {
- Gdx.gl.glClearColor(1, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- super.render();
- stage.draw();
- }
- }
- Output:
- package com.marsminer.game;
- import com.badlogic.gdx.ApplicationAdapter;
- import com.badlogic.gdx.Game;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.assets.AssetManager;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.Batch;
- import com.badlogic.gdx.graphics.g2d.BitmapFont;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.graphics.g2d.TextureAtlas;
- import com.badlogic.gdx.scenes.scene2d.Stage;
- import com.badlogic.gdx.scenes.scene2d.ui.Skin;
- import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
- import java.awt.Color;
- import sun.applet.Main;
- public class MarsMiner extends Game {
- Stage stage;
- TextButton button;
- TextButton.TextButtonStyle textButtonStyle;
- BitmapFont font;
- Skin skin;
- TextureAtlas textureAtlas;
- @Override
- public void create () {
- stage = new Stage();
- Gdx.input.setInputProcessor(stage);
- font = new BitmapFont();
- skin = new Skin();
- textureAtlas = new TextureAtlas(Gdx.files.internal("buttons/buttons.pack"));
- skin.addRegions(textureAtlas);
- textButtonStyle = new TextButton.TextButtonStyle();
- textButtonStyle.font = font;
- textButtonStyle.up = skin.getDrawable("up-button");
- textButtonStyle.down = skin.getDrawable("down-button");
- textButtonStyle.checked = skin.getDrawable("checked-button");
- button = new TextButton("Button1", textButtonStyle);
- stage.addActor(button);
- }
- @Override
- public void render () {
- Gdx.gl.glClearColor(1, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- super.render();
- stage.draw();
- }
- }
- Output:
- Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: File not found: buttons\buttons.pack (Internal)
- at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
- at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.<init>(TextureAtlas.java:103)
- at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:231)
- at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:226)
- at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:216)
- at com.marsminer.game.MarsMiner.create(MarsMiner.java:35)
- at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
- at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement