Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tk.tharline.minefinder.screen;
- import tk.tharline.minefinder.*;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Screen;
- import com.badlogic.gdx.graphics.GL20;
- 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.TextureAtlas;
- import com.badlogic.gdx.scenes.scene2d.InputEvent;
- import com.badlogic.gdx.scenes.scene2d.InputListener;
- import com.badlogic.gdx.scenes.scene2d.Stage;
- import com.badlogic.gdx.scenes.scene2d.ui.Image;
- import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
- import com.badlogic.gdx.scenes.scene2d.ui.Skin;
- public class MenuScreen implements Screen{
- private MineFinder game;
- private Stage stage;
- private TextureAtlas atlas;
- private Skin skin;
- private SpriteBatch batch;
- private ImageButton button;
- private Texture background;
- private Image asd;
- private Sprite bg;
- public MenuScreen(MineFinder game){
- this.game = game;
- }
- @Override
- public void render(float delta) {
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- stage.act(delta);
- batch.begin();
- stage.draw();
- batch.end();
- }
- @Override
- public void resize(int width, int height) {
- if(stage == null){
- stage = new Stage(width, height, true);
- }
- stage.clear();
- Gdx.input.setInputProcessor(stage);
- background = new Texture(Gdx.files.internal("data/pali/mine-start.jpg"));
- bg = new Sprite(background);
- background.setFilter(TextureFilter.Linear, TextureFilter.Linear);
- asd = new Image(bg);
- asd.setX(0);
- asd.setY(0);
- button = new ImageButton(skin.getDrawable("on_start"), skin.getDrawable("on_start_two"));
- button.setColor(1, 1, 1, 1);
- button.setX(Gdx.graphics.getWidth() / 2 - button.getWidth() / 2);
- button.setY(Gdx.graphics.getHeight() / 2 - button.getHeight() / 2 - 130);
- button.addListener(new InputListener(){
- @Override
- public boolean touchDown(InputEvent event, float x, float y, int pointer, int button){
- return true;
- }
- @Override
- public void touchUp(InputEvent event, float x, float y, int pointer, int button){
- MineFinder.Log.debug("xpos: " + x + ", ypos: " + y);
- game.setScreen(new GameScreen(game));
- }
- });
- stage.addActor(asd);
- stage.addActor(button);
- }
- @Override
- public void show() {
- batch = new SpriteBatch();
- atlas = new TextureAtlas("data/buttons.pack");
- skin = new Skin();
- skin.addRegions(atlas);
- }
- @Override
- public void hide() {
- }
- @Override
- public void pause() {
- }
- @Override
- public void resume() {
- }
- @Override
- public void dispose() {
- batch.dispose();
- skin.dispose();
- atlas.dispose();
- stage.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement