Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Skin#add()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.Skin#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkinLoader.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
static Skin loadSkin() { String folder = "ui/x" + bestMultiplier + "/"; // Base skin Skin skin = new Skin(Gdx.files.internal("skin/uiskin.json")); // Nine patches final int border = (int) (28 * bestMultiplier); skin.add("button_up", new NinePatch(new Texture( Gdx.files.internal(folder + "button_up.png")), border, border, border, border)); skin.add("button_down", new NinePatch(new Texture( Gdx.files.internal(folder + "button_down.png")), border, border, border, border)); for (String id : ids) { skin.add(id + "_texture", new Texture(Gdx.files.internal(folder + id + ".png"))); } folder = "font/x" + bestMultiplier + "/"; skin.add("font", new BitmapFont(Gdx.files.internal(folder + "geosans-light64.fnt"))); skin.add("font_small", new BitmapFont(Gdx.files.internal(folder + "geosans-light32.fnt"))); skin.add("font_bonus", new BitmapFont(Gdx.files.internal(folder + "the-next-font.fnt"))); return skin; }
Example 2
Source File: JoystickControl.java From TerraLegion with MIT License | 6 votes |
public JoystickControl(Texture background, Texture knob, float deadZoneRadius, float x, float y, float width, float height) { touchpadSkin = new Skin(); //Set background image touchpadSkin.add("touchBackground", background); //Set knob image touchpadSkin.add("touchKnob", knob); //Create TouchPad Style touchpadStyle = new TouchpadStyle(); //Apply the Drawables to the TouchPad Style touchpadStyle.background = touchpadSkin.getDrawable("touchBackground"); touchpadStyle.knob = touchpadSkin.getDrawable("touchKnob"); //Create new TouchPad with the created style touchpad = new Touchpad(deadZoneRadius, touchpadStyle); //setBounds(x,y,width,height) touchpad.setBounds(x, y, width, height); }
Example 3
Source File: Main.java From xibalba with MIT License | 4 votes |
/** * Setup & load the main menu. */ public void create() { // Debug shit debug = new Debug(); // Load custom font assets = new AssetManager(); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("ui/Aller_Rg.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = 12; BitmapFont font = generator.generateFont(parameter); generator.dispose(); // Create UI skin skin = new Skin(); skin.add("Aller", font, BitmapFont.class); skin.addRegions(new TextureAtlas(Gdx.files.internal("ui/uiskin.atlas"))); skin.load(Gdx.files.internal("ui/uiskin.json")); skin.getFont("default-font").getData().markupEnabled = true; // Setup text colors Colors.put("LIGHT_GRAY", parseColor("c2c2c2")); Colors.put("DARK_GRAY", parseColor("666666")); Colors.put("CYAN", parseColor("67C8CF")); Colors.put("RED", parseColor("D67474")); Colors.put("YELLOW", parseColor("E0DFB1")); Colors.put("GREEN", parseColor("67CF8B")); // Environment colors Colors.put("forestFloor", parseColor("78AD8A")); Colors.put("forestFloorWet", parseColor("70BBAD")); Colors.put("forestTree-1", parseColor("67CF8B")); Colors.put("forestTree-2", parseColor("77E09B")); Colors.put("forestTree-3", parseColor("4AC775")); Colors.put("caveFloor-1", parseColor("7A7971")); Colors.put("caveFloor-2", parseColor("8C8B82")); Colors.put("caveFloor-3", parseColor("696862")); Colors.put("caveFloorWet", parseColor("71A48E")); Colors.put("caveWall", parseColor("66655C")); Colors.put("waterShallowLightBlue", parseColor("67C8CF")); Colors.put("waterShallowDarkBlue", parseColor("139EA8")); Colors.put("waterDeepLightBlue", parseColor("139EA8")); Colors.put("waterDeepDarkBlue", parseColor("0B7880")); Colors.put("waterShallowLightGreen", parseColor("67CFAB")); Colors.put("waterShallowDarkGreen", parseColor("13A88F")); Colors.put("waterDeepLightGreen", parseColor("13A88F")); Colors.put("waterDeepDarkGreen", parseColor("0B8074")); Colors.put("fire-1", parseColor("ED6161")); Colors.put("fire-2", parseColor("EDBE61")); Colors.put("fire-3", parseColor("ED9661")); // Decoration colors Colors.put("stone", Colors.get("LIGHT_GRAY")); Colors.put("bridge", parseColor("969482")); // Background colors Colors.put("screenBackground", parseColor("293033")); Colors.put("forestBackground", parseColor("29332F")); Colors.put("caveBackground", parseColor("293033")); // Tween manager tweenManager = new TweenManager(); Tween.setCombinedAttributesLimit(4); Tween.registerAccessor(Sprite.class, new SpriteAccessor()); // Cameras handheldCamera = new HandheldCamera(); cameraShake = new CameraShake(); // Start the main menu setScreen(new LoadingScreen(this)); }
Example 4
Source File: onScreenControls.java From killingspree with MIT License | 4 votes |
public onScreenControls() { stage = new Stage(); skin = new Skin(); skin.add("buttonA", new Texture("controls/buttonA.png")); skin.add("buttonB", new Texture("controls/buttonB.png")); skin.add("buttonX", new Texture("controls/buttonX.png")); skin.add("buttonLeft", new Texture("controls/buttonLeft.png")); skin.add("buttonRight", new Texture("controls/buttonRight.png")); skin.add("buttonUp", new Texture("controls/buttonUp.png")); skin.add("closeButton", new Texture("controls/closeButton.png")); Drawable button; button = skin.getDrawable("buttonLeft"); leftButton = new Button(button); leftButton.setColor(leftButton.getColor().r, leftButton.getColor().g, leftButton.getColor().b, leftButton.getColor().a / 5); button = skin.getDrawable("buttonRight"); rightButton = new Button(button); rightButton.setColor(rightButton.getColor().r, rightButton.getColor().g, rightButton.getColor().b, rightButton.getColor().a / 5); button = skin.getDrawable("buttonUp"); upButton = new Button(button); upButton.setColor(upButton.getColor().r, upButton.getColor().g, upButton.getColor().b, upButton.getColor().a / 5); button = skin.getDrawable("buttonA"); jumpButton = new Button(button); jumpButton.setColor(jumpButton.getColor().r, jumpButton.getColor().g, jumpButton.getColor().b, jumpButton.getColor().a / 5); button = skin.getDrawable("buttonX"); shootButton = new Button(button); shootButton.setColor(shootButton.getColor().r, shootButton.getColor().g, shootButton.getColor().b, shootButton.getColor().a / 5); button = skin.getDrawable("buttonB"); throwBombButton = new Button(button); throwBombButton.setColor(throwBombButton.getColor().r, throwBombButton.getColor().g, throwBombButton.getColor().b, throwBombButton.getColor().a / 5); button = skin.getDrawable("closeButton"); closeButton = new Button(button); closeButton.setColor(closeButton.getColor().r, closeButton.getColor().g, closeButton.getColor().b, closeButton.getColor().a / 5); this.stage.addActor(jumpButton); this.stage.addActor(shootButton); this.stage.addActor(throwBombButton); this.stage.addActor(closeButton); this.stage.addActor(upButton); this.stage.addActor(rightButton); this.stage.addActor(leftButton); Gdx.input.setInputProcessor(stage); resize(); }