List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Skin Skin
public Skin()
From source file:com.bagon.matchteam.mtx.asset.AbstractAssets.java
License:Apache License
public AbstractAssets() { assetManager = new AssetManager(); skin = new Skin(); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createLevelAndHealthLayer() { Stage stage = new Stage(new StretchViewport(486, 864)); Skin skin = new Skin(); Table table = new Table(); table.top().pad(10);/* ww w. j a v a 2 s . c o m*/ FreeTypeFontGenerator generator = new FreeTypeFontGenerator( Gdx.files.internal("ui/fonts/Century Gothic Bold.ttf")); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.size = 40; parameter.borderColor = Color.BLACK; parameter.borderWidth = 3; BitmapFont font = generator.generateFont(parameter); generator.dispose(); Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE); skin.add("star", new Texture("ui/icons/star.png")); skin.add("shield", new Texture("ui/icons/shield.png")); skin.add("brick", new Texture("ui/icons/brick.png")); skin.add("swipe128", new Texture("ui/icons/swipe128.png")); float padding = 10; Image icon = new Image(skin.getDrawable("star")); if (Global.debugLevelUp) { icon.addListener(new ClickListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (Engine.systemManager.has(LevelProgressionSystem.class)) { for (Entity entity : Engine.systemManager.get(LevelProgressionSystem.class).entities) { Engine.garbageManager.markForDeletion(entity); } } super.touchUp(event, x, y, pointer, button); } }); } table.add(icon).pad(padding); Label levelLabel = new Label("", labelStyle); table.add(levelLabel).pad(padding); icon = new Image(skin.getDrawable("shield")); table.add(icon).pad(padding); Label healthLabel = new Label("", labelStyle); table.add(healthLabel).pad(padding); icon = new Image(skin.getDrawable("brick")); table.add(icon).pad(padding); Label brickLabel = new Label("", labelStyle); table.add(brickLabel).pad(padding); table.row(); // swipe if (Engine.systemManager.has(LevelProgressionSystem.class)) { if (Engine.systemManager.get(LevelProgressionSystem.class).level < 5) { icon = new Image(skin.getDrawable("swipe128")); table.add(icon).padTop(350).colspan(6); Global.swipeIcon = icon; } } // table.setDebug(true); table.setFillParent(true); stage.addActor(table); Global.LEVEL_LABEL = levelLabel; Global.HEALTH_LABEL = healthLabel; Global.BRICK_LABEL = brickLabel; if (Engine.systemManager.has(LevelProgressionSystem.class)) { Global.LEVEL_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).level); Global.HEALTH_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).health); Global.BRICK_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).nrOfBricks); } Engine.inputManager.add(stage); return new Layer("topLayer", stage, table); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createScoreLayer() { Stage stage = new Stage(); Table table = new Table(); BitmapFont font = new BitmapFont(); font.scale(2);// w ww . j a v a2s . c o m Button button; Skin skin = new Skin(); skin.add("bluebox", new Texture("textures/bluebox.jpg")); skin.add("greenbox", new Texture("textures/greenbox.jpg")); skin.add("redbox", new Texture("textures/redbox2.jpg")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("redbox"), skin.getDrawable("greenbox"), skin.getDrawable("bluebox"), font); button = new ImageTextButton("0", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); table.add(button).pad(5).center(); table.pack(); table.setPosition(Gdx.graphics.getWidth() / 2 - table.getWidth() / 2, Gdx.graphics.getHeight() - table.getHeight()); stage.addActor(table); Global.scoreButton = button; return new Layer("scoreLayer", stage); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createFireLayer() { Stage stage = new Stage(new StretchViewport(640, 480)); Table table = new Table(); BitmapFont font = new BitmapFont(); Button button;//from w w w.j a v a 2 s . c o m Skin skin = new Skin(); skin.add("bluebox", new Texture("textures/bluebox.jpg")); skin.add("greenbox", new Texture("textures/greenbox.jpg")); skin.add("redbox", new Texture("textures/redbox.jpg")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("redbox"), skin.getDrawable("greenbox"), skin.getDrawable("bluebox"), font); button = new ImageTextButton("Fire", style); button.setHeight(50); button.setWidth(50); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Gdx.input.getInputProcessor().keyDown(Keys.SPACE); return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { Gdx.input.getInputProcessor().keyUp(Keys.SPACE); } }); table.add(button).pad(50).center(); table.pack(); table.setPosition(640 - table.getWidth(), 0); stage.addActor(table); Engine.inputManager.add(stage); return new Layer("fireLayer", stage); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createJoystickLayer() { Stage stage = new Stage(new StretchViewport(1280, 720)); Table table = new Table(); MyListener listener = new MyListener(); BitmapFont font = new BitmapFont(); Button button;//from w w w .j av a 2s .c o m Skin skin = new Skin(); skin.add("cirlce", new Texture("textures/circle.png")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), font); button = new ImageTextButton("Move", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new MoveListener()); table.add(button).pad(50).expandX().left(); button = new ImageTextButton("Fire", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(listener); table.add(button).pad(50).bottom().right(); table.setDebug(true); table.setFillParent(true); table.bottom().left(); stage.addActor(table); Engine.inputManager.add(stage); return new Layer("joystickLayer", stage); }
From source file:com.blackboxgaming.engine.factories.LayerFactory.java
public static Layer createJoystickControlLayer() { Stage stage = new Stage(new StretchViewport(1280, 720)); Table table = new Table(); BitmapFont font = new BitmapFont(); Button button;//w w w. ja v a2s .c om Skin skin = new Skin(); skin.add("cirlce", new Texture("textures/circle.png")); ImageTextButtonStyle style = new ImageTextButtonStyle(skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), skin.getDrawable("cirlce"), font); button = new ImageTextButton("Debug Options", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Engine.game.setScreen(Engine.screens.get("debug")); return false; } }); table.add(button).pad(50).padLeft(100).expandX().left(); table.row(); button = new ImageTextButton("L Boost", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(true, false, true)); table.add(button).pad(50).padLeft(100).expandX().left(); button = new ImageTextButton("R Boost", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(false, true, true)); table.add(button).pad(50).padRight(100).bottom().right(); table.row(); button = new ImageTextButton("Left", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(true, false, false)); table.add(button).pad(50).padLeft(100).expandX().left(); button = new ImageTextButton("Right", style); button.setHeight(150); button.setWidth(150); button.setName(((ImageTextButton) button).getText().toString()); button.addListener(new Rotate(false, true, false)); table.add(button).pad(50).padRight(100).bottom().right(); // table.setDebug(true); table.setFillParent(true); table.bottom().left(); stage.addActor(table); if (Engine.systemManager.has(OrbitCameraSystem.class) && Engine.systemManager.get(OrbitCameraSystem.class).mouseListener) { InputProcessor tmp = Engine.systemManager.get(OrbitCameraSystem.class).orbitCameraController; Engine.inputManager.remove(tmp); Engine.inputManager.add(stage); Engine.inputManager.add(tmp); } else { Engine.inputManager.add(stage); } return new Layer("controlLayer", stage); }
From source file:com.eightpuzzle.game.EightPuzzle.java
License:Apache License
@Override public void create() { gameFont = new BitmapFont(); solvedFont = new BitmapFont(); batch = new SpriteBatch(); aspectRatio = (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth(); OrthographicCamera camera = new OrthographicCamera(GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio); //camera.position.set(GAME_WIDTH/2, GAME_HEIGHT/2, 0) camera.setToOrtho(false, GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio); //camera.setToOrtho(false,GAME_WIDTH,GAME_HEIGHT); stage = new Stage(new ExtendViewport(GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio, camera));//Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera)); Gdx.input.setInputProcessor(stage);//from w w w .j a v a 2 s. co m // A skin can be loaded via JSON or defined programmatically, either is fine. Using a skin is optional but strongly // recommended solely for the convenience of getting a texture, region, etc as a drawable, tinted drawable, etc. skin = new Skin(); // Generate a 1x1 white texture and store it in the skin named "white". Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888); pixmap.setColor(Color.WHITE); pixmap.fill(); skin.add("white", new Texture(pixmap)); // Store the default libgdx font under the name "default". skin.add("default", new BitmapFont()); // Configure a TextButtonStyle and name it "default". Skin resources are stored by type, so this doesn't overwrite the font. TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY); textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY); //textButtonStyle.checked = skin.newDrawable("white", Color.BLUE); textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY); textButtonStyle.font = skin.getFont("default"); skin.add("default", textButtonStyle); Label.LabelStyle labelSty = new Label.LabelStyle(); labelSty.font = skin.getFont("default"); //labelSty.fontColor = Color.GREEN; skin.add("default", labelSty); WindowStyle ws = new Window.WindowStyle(); ws.titleFont = new BitmapFont(); ws.background = skin.newDrawable("white", Color.BLACK); skin.add("default", ws); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Zig.ttf")); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.size = 25; gameFont = generator.generateFont(parameter); FreeTypeFontParameter parameter2 = new FreeTypeFontParameter(); parameter2.size = 100; parameter2.color = Color.GREEN; solvedFont = generator.generateFont(parameter2); generator.dispose(); FileHandle blue, n1, n2, n3, n4, n5, n6, n7, n8, solveUp, solveDown; if (Gdx.app.getType() == ApplicationType.Desktop) { blue = Gdx.files.internal("icons64px/blue-square.png"); n1 = Gdx.files.internal("icons64px/Number-1-icon.png"); n2 = Gdx.files.internal("icons64px/Number-2-icon.png"); n3 = Gdx.files.internal("icons64px/Number-3-icon.png"); n4 = Gdx.files.internal("icons64px/Number-4-icon.png"); n5 = Gdx.files.internal("icons64px/Number-5-icon.png"); n6 = Gdx.files.internal("icons64px/Number-6-icon.png"); n7 = Gdx.files.internal("icons64px/Number-7-icon.png"); n8 = Gdx.files.internal("icons64px/Number-8-icon.png"); solveUp = blue; solveDown = blue; } else { blue = Gdx.files.internal("icons256px/blue-circle.png"); n1 = Gdx.files.internal("icons256px/Number-1-icon.png"); n2 = Gdx.files.internal("icons256px/Number-2-icon.png"); n3 = Gdx.files.internal("icons256px/Number-3-icon.png"); n4 = Gdx.files.internal("icons256px/Number-4-icon.png"); n5 = Gdx.files.internal("icons256px/Number-5-icon.png"); n6 = Gdx.files.internal("icons256px/Number-6-icon.png"); n7 = Gdx.files.internal("icons256px/Number-7-icon.png"); n8 = Gdx.files.internal("icons256px/Number-8-icon.png"); solveUp = Gdx.files.internal("icons256px/Box_Green.png"); solveDown = Gdx.files.internal("icons256px/rectangle_green.png"); } Texture bSquare = new Texture(blue); Texture n1T = new Texture(n1); Texture n2T = new Texture(n2); Texture n3T = new Texture(n3); Texture n4T = new Texture(n4); Texture n5T = new Texture(n5); Texture n6T = new Texture(n6); Texture n7T = new Texture(n7); Texture n8T = new Texture(n8); TextureRegion bSquareReg = new TextureRegion(bSquare); TextureRegion n1Reg = new TextureRegion(n1T); TextureRegion n2Reg = new TextureRegion(n2T); TextureRegion n3Reg = new TextureRegion(n3T); TextureRegion n4Reg = new TextureRegion(n4T); TextureRegion n5Reg = new TextureRegion(n5T); TextureRegion n6Reg = new TextureRegion(n6T); TextureRegion n7Reg = new TextureRegion(n7T); TextureRegion n8Reg = new TextureRegion(n8T); TextureRegionDrawable solveDUp = new TextureRegionDrawable(new TextureRegion(new Texture(solveUp))); TextureRegionDrawable solveDDown = new TextureRegionDrawable(new TextureRegion(new Texture(solveDown))); ImageTextButton.ImageTextButtonStyle tbSty = new ImageTextButton.ImageTextButtonStyle(solveDUp, solveDDown, solveDUp, gameFont); skin.add("default", tbSty); ImageButtonStyle bSquareSty = new ImageButtonStyle(); bSquareSty.imageUp = new TextureRegionDrawable(bSquareReg); bSquareSty.imageDown = new TextureRegionDrawable(bSquareReg); ImageButtonStyle n1Sty = new ImageButtonStyle(); n1Sty.imageUp = new TextureRegionDrawable(n1Reg); n1Sty.imageDown = new TextureRegionDrawable(n1Reg); ImageButtonStyle n2Sty = new ImageButtonStyle(); n2Sty.imageUp = new TextureRegionDrawable(n2Reg); n2Sty.imageDown = new TextureRegionDrawable(n2Reg); ImageButtonStyle n3Sty = new ImageButtonStyle(); n3Sty.imageUp = new TextureRegionDrawable(n3Reg); n3Sty.imageDown = new TextureRegionDrawable(n3Reg); ImageButtonStyle n4Sty = new ImageButtonStyle(); n4Sty.imageUp = new TextureRegionDrawable(n4Reg); n4Sty.imageDown = new TextureRegionDrawable(n4Reg); ImageButtonStyle n5Sty = new ImageButtonStyle(); n5Sty.imageUp = new TextureRegionDrawable(n5Reg); n5Sty.imageDown = new TextureRegionDrawable(n5Reg); ImageButtonStyle n6Sty = new ImageButtonStyle(); n6Sty.imageUp = new TextureRegionDrawable(n6Reg); n6Sty.imageDown = new TextureRegionDrawable(n6Reg); ImageButtonStyle n7Sty = new ImageButtonStyle(); n7Sty.imageUp = new TextureRegionDrawable(n7Reg); n7Sty.imageDown = new TextureRegionDrawable(n7Reg); ImageButtonStyle n8Sty = new ImageButtonStyle(); n8Sty.imageUp = new TextureRegionDrawable(n8Reg); n8Sty.imageDown = new TextureRegionDrawable(n8Reg); ImageButton b1 = new ImageButton(n1Sty); b1.addListener(new MyChangeListener(1)); map.put(1, b1); ImageButton holeB = new ImageButton(bSquareSty); map.put(0, holeB); ImageButton ib = new ImageButton(n2Sty); ib.addListener(new MyChangeListener(2)); map.put(2, ib); ImageButton b4 = new ImageButton(n3Sty); b4.addListener(new MyChangeListener(3)); ImageButton b5 = new ImageButton(n4Sty); b5.addListener(new MyChangeListener(4)); ImageButton b6 = new ImageButton(n5Sty); b6.addListener(new MyChangeListener(5)); map.put(3, b4); map.put(4, b5); map.put(5, b6); ImageButton b7 = new ImageButton(n6Sty); b7.addListener(new MyChangeListener(6)); ImageButton b8 = new ImageButton(n7Sty); b8.addListener(new MyChangeListener(7)); ImageButton b9 = new ImageButton(n8Sty); b9.addListener(new MyChangeListener(8)); map.put(6, b7); map.put(7, b8); map.put(8, b9); newGameB = new ImageTextButton("New Game", skin); newGameB.addListener(new NewGameListener()); solveB = new ImageTextButton("Solve", skin); solveB.addListener(new MySolveListener()); newGameBoard(); //table.padTop(50); //table.padBottom(20); VerticalGroup vg = new VerticalGroup(); //vg.padTop(50); vg.setFillParent(true); vg.addActor(newGameB); vg.addActor(table); vg.addActor(solveB); stage.addActor(vg); }
From source file:com.entermoor.blackandwhiteforest.BlackAndWhiteForest.java
License:Creative Commons License
@Override public void create() { try {/*from www . jav a 2 s. c o m*/ Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); welcome = new ScreenWelcome(); main = new ScreenMain(); settings = new ScreenSettings(); gaming = new ScreenGaming(); skin = new Skin(); while (!assetManager.update()) ; WindowStyle windowStyle = new WindowStyle(new BitmapFont(), Color.BLACK, new TextureRegionDrawable( new TextureRegion((Texture) assetManager.get("textures/dialogBackground.png", Texture.class)))); skin.add("default", windowStyle); LabelStyle labelStyle = new LabelStyle(new BitmapFont(), Color.WHITE); skin.add("default", labelStyle); for (IBAWFPlugin plugin : toInitList) plugin.init(); addProcessor(stage); addProcessor(new InputProcessor() { @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean scrolled(int amount) { return false; } @Override public boolean mouseMoved(int screenX, int screenY) { return false; } @Override public boolean keyUp(int keycode) { if (keycode == Keys.ESCAPE) { Gdx.app.exit(); } return false; } @Override public boolean keyTyped(char character) { return false; } @Override public boolean keyDown(int keycode) { return false; } }); } catch (Throwable t) { BAWFCrashHandler.handleCrash(t); } currentBGM = bgm[new Random().nextInt(bgm.length)]; currentBGM.play(); setScreen(welcome); }
From source file:com.evoluzion.MenuInicio.java
License:Open Source License
public MenuInicio(Evoluzion ev) { this.ev = ev; tx = new Texto(); //m= new Mundo(ev,"",0,50,50,20,20,false); camara = new OrthographicCamera(); camara.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); f2 = new File("evo_star.conf"); batch = new SpriteBatch(); fuente = new BitmapFont(); ta_atlas = new TextureAtlas("data/botones.pack");//carga el atlas de texturas donde estan los botones ta_atlas2 = new TextureAtlas("data/boxes.pack"); sk_skin = new Skin(); sk_skin.addRegions(ta_atlas);/*from ww w .jav a 2 s .c o m*/ sk_skin2 = new Skin(); sk_skin2.addRegions(ta_atlas2); fu_fuente = new BitmapFont(); //fu_titulo = new BitmapFont(Gdx.files.internal("data/fMensage.fnt"),false); // tx_titulo = new Texture("data/titulo.png"); // titulo = new Sprite(tx_titulo); // titulo.setSize(500,100); // titulo.setPosition(50,550); rectangulo = new ShapeRenderer(); a_ruta = new Archivar(); a_idioma = new Archivar(); leerRuta(); leerIdioma(); if (ingles == 1) { tx.setIngles(); } if (ingles == -1) { tx.setEspanol(); } controles(); //System.out.println("idioma "+ingles); leerMenuIncio(); }
From source file:com.evoluzion.Pantalla.java
License:Open Source License
public Pantalla(Evoluzion ev, Mundo m) { this.ev = ev; this.m = m;//w ww . j av a 2 s. c o m tx = m.tx;//usamos la configuracionde taxto del menu inicio or = m.aorg.get(0); se = m.ase.get(0); qe = m.aqe.get(0); camara = new OrthographicCamera(); camara.setToOrtho(false, m.ancho, m.alto); batch = new SpriteBatch(); caja = new ShapeRenderer(); borde = new ShapeRenderer(); fuente = new BitmapFont(); ta_atlas = new TextureAtlas("data/botones.pack");//carga el atlas de texturas donde estan los botones ta_atlas2 = new TextureAtlas("data/boxes.pack"); sk_skin = new Skin(); sk_skin.addRegions(ta_atlas); sk_skin2 = new Skin(); sk_skin2.addRegions(ta_atlas2); fu_fuente = new BitmapFont(); //colecta los datos del tiempo 0 // m.archivarGenoma(); // m.archivarProteoma(); // m.guardarDatos(); }