Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Skin

The following are top voted examples for showing how to use com.badlogic.gdx.scenes.scene2d.ui.Skin. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ProjektGG   File: LoadingScreen.java   View source code 6 votes vote down vote up
private void onFinishedLoading() {
	BitmapFont main19Font = assetManager.get(MAIN_FONT_19_PATH());
	BitmapFont main22Font = assetManager.get(MAIN_FONT_22_PATH());
	BitmapFont letter20Font = assetManager.get(LETTER_FONT_20_PATH());
	BitmapFont handwritten20Font = assetManager
			.get(HANDWRITTEN_FONT_20_PATH());

	ObjectMap<String, Object> fontMap = new ObjectMap<String, Object>();
	fontMap.put("main-19", main19Font);
	fontMap.put("main-22", main22Font);
	fontMap.put("letter-20", letter20Font);
	fontMap.put("handwritten-20", handwritten20Font);
	assetManager.load(SKIN_PATH, Skin.class,
			new SkinLoader.SkinParameter(SKIN_TEXTURE_ATLAS_PATH, fontMap));
	assetManager.finishLoadingAsset(SKIN_PATH);

	// game.setUISkin(assetManager.get(SKIN_PATH));
	VisUI.load();
	game.setUISkin(VisUI.getSkin());

	// Notify loaded screens
	game.getScreen("serverBrowser").finishLoading();

	game.pushScreen("mainMenu");
}
 
Example 2
Project: Hexpert   File: BuildingScoreDialog.java   View source code 6 votes vote down vote up
public BuildingScoreDialog(Hexpert hexpert, Skin skin) {
    super(hexpert, skin, false);
    
    getContentTable().defaults().pad(15);
    Label.LabelStyle lblStyle = skin.get("bigger", Label.LabelStyle.class);
    Label lblExplaination = new Label(hexpert.i18NBundle.get("tut_score"), skin);
    lblExplaination.setWrap(true);
    lblExplaination.setAlignment(Align.center);
    getContentTable().add(lblExplaination).colspan(8).width(8*160);
    lblExplaination.setWrap(true);
    getContentTable().row();

    for (int i = 1; i < BuildingType.values().length; i++) {
        BuildingType buildingType = BuildingType.values()[i];
        Image image = new Image(new TextureRegion((Texture)
                hexpert.assetManager.get(SPRITE_FOLDER + buildingType.name().toLowerCase() + "_min.png")));

        getContentTable().add(image).width(160).height(160);
        Label lblScore = new Label(Integer.toString(buildingType.getScore()), lblStyle);
        lblScore.setAlignment(Align.center);
        getContentTable().add(lblScore).expand();
        if (i % 4 == 0)
            getContentTable().row();
    }
}
 
Example 3
Project: LD38-Compo   File: LudumDare38.java   View source code 6 votes vote down vote up
private void createResetButton()
{
	Skin skin = new Skin();
	Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	pixmap.setColor(Color.WHITE);
	pixmap.fill();
	skin.add("white", new Texture(pixmap));
	skin.add("default", new BitmapFont());

	TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
	textButtonStyle.up = skin.newDrawable("white", new Color(0, 0, 0, 1));
	textButtonStyle.font = skin.getFont("default");
	skin.add("default", textButtonStyle);

	btnReset = new TextButton("RESET", skin);
	btnReset.setX(5);
	btnReset.setY(Gdx.graphics.getHeight() - 25);
	btnReset.setWidth(60);
	btnReset.setVisible(true);
	group.addActor(btnReset);
}
 
Example 4
Project: LD38-Compo   File: LudumDare38.java   View source code 6 votes vote down vote up
private void createUndoButton()
{
	Skin skin = new Skin();
	Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	pixmap.setColor(Color.WHITE);
	pixmap.fill();
	skin.add("white", new Texture(pixmap));
	skin.add("default", new BitmapFont());

	TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
	textButtonStyle.up = skin.newDrawable("white", new Color(0, 0, 0, 1));
	textButtonStyle.font = skin.getFont("default");
	skin.add("default", textButtonStyle);

	btnUndo = new TextButton("UNDO", skin);
	btnUndo.setX(70);
	btnUndo.setY(Gdx.graphics.getHeight() - 25);
	btnUndo.setWidth(60);
	btnUndo.setVisible(true);
	group.addActor(btnUndo);
}
 
Example 5
Project: Catan   File: CatanGame.java   View source code 6 votes vote down vote up
@Override
public void create() {
    batch = new SpriteBatch();

    // Load the UI skin
    skin = new Skin(Gdx.files.internal("skin/uiskin.json"));

    clickSound = Gdx.audio.newSound(Gdx.files.internal("sound/buttonClick.mp3"));
    menuMusic = Gdx.audio.newMusic(Gdx.files.internal("sound/menuMusic.mp3"));
    menuMusic.setLooping(true);

    // Load the current account if cached
    account = AccountManager.getLocalAccount();
    // The first screen that shows up when the game starts
    Screen mainScreen = account == null ? new LoginScreen(this) : new MenuScreen(this);
    setScreen(mainScreen);
}
 
Example 6
Project: blueirisviewer   File: MainOptionsWnd.java   View source code 6 votes vote down vote up
private void AddWindowButton(final UIElement window, String buttonText, Skin skin, Table table)
{
	final TextButton btn = new TextButton(buttonText, skin);

	btn.addListener(new ChangeListener()
	{
		@Override
		public void changed(ChangeEvent event, Actor actor)
		{
			if (window.isShowing())
				window.hide();
			else
				window.show();
		}
	});

	table.add(btn);
	table.row();
}
 
Example 7
Project: GDX-Engine   File: BuildWeaponGUI.java   View source code 6 votes vote down vote up
@Override
   protected void onBuild(Skin skin) {
btnAddGun = new TextButton("Add Gun Lv.1 ($" + GameSpecs.gun_cost_first
	+ ")", skin);
row().fill().expandX();
add(btnAddGun).expandX();
btnAddCanon = new TextButton("Add Canon Lv.1 ($"
	+ GameSpecs.canon_cost_first + ")", skin);
row().fill().expandX();
add(btnAddCanon).expandX();
btnAddSlower = new TextButton("Add Slower Lv.1 ($"
	+ GameSpecs.slower_cost_first + ")", skin);
row().fill().expandX();
add(btnAddSlower).expandX();
super.onBuild(skin);
   }
 
Example 8
Project: GDX-Engine   File: GameDialog.java   View source code 6 votes vote down vote up
public GameDialog(Skin skin) {
super("", skin);

waveLevel = new Label("", skin);
monsHP = new Label("", skin);
monsBonus = new Label("", skin);
monsSpeed = new Label("", skin);
monsNumber = new Label("", skin);
btnOK = new TextButton("Okay, Let them come!", skin);
btnOK.addListener(new ChangeListener() {

    @Override
    public void changed(ChangeEvent event, Actor actor) {
	// TODO Auto-generated method stub
	setVisible(false);

    }
});
setTitle(" There are more monsters are coming to you... ");
   }
 
Example 9
Project: Hexpert   File: ActionDialog.java   View source code 6 votes vote down vote up
public ActionDialog(Label text, Action action, I18NBundle bundle, Skin skin, Hexpert hexpert) {
    super(hexpert, skin);
    this.action = action;

    getBackground().setMinWidth(1000);
    getBackground().setMinHeight(400);
    text.setWrap(true);
    text.setAlignment(Align.center);

    getContentTable().add(text).width(getBackground().getMinWidth()).expandX();

    getButtonTable().defaults().width(200).height(120).pad(15);

    TextButton textButtonYes = new TextButton(bundle.get("yes"), skin);
    getButtonTable().add(textButtonYes);
    setObject(textButtonYes, 1);
    TextButton textButtonNo = new TextButton(bundle.get("no"), skin);
    getButtonTable().add(textButtonNo);
    setObject(textButtonNo, null);
}
 
Example 10
Project: enklave   File: ProgressBarEnergy.java   View source code 6 votes vote down vote up
public void updateVisual(){
    Skin skin = new Skin();
    Pixmap pixmap = new Pixmap(1,(int)(Gdx.graphics.getHeight()*0.0175), Pixmap.Format.RGBA8888);
    switch (infoProfile.getDateUserGame().getFaction()){
        case 1:{
            pixmap.setColor(1, 0f, 0f, 1);
            break;
        }
        case 2:{
            pixmap.setColor(0f, 0.831f, 0.969f,1f);
            break;
        }
        case 3:{
            pixmap.setColor(0.129f, 0.996f, 0.29f,1);
            break;
        }
    }
    pixmap.fill();
    skin.add("blue", new Texture(pixmap));
    ProgressBar.ProgressBarStyle style = new ProgressBar.ProgressBarStyle(bar.getStyle().background,skin.newDrawable("blue",Color.WHITE));
    style.knobBefore = style.knob;
    bar.setStyle(style);
}
 
Example 11
Project: GangsterSquirrel   File: MenuScreen.java   View source code 6 votes vote down vote up
public MenuScreen(MainGameClass game) {
    this.game = game;

    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);

    skin = new Skin(Gdx.files.internal("skins/Flat_Earth_UI_Skin/flatearthui/flat-earth-ui.json"));

    progressBarStyle = skin.get("fancy", ProgressBar.ProgressBarStyle.class);
    TiledDrawable tiledDrawable = skin.getTiledDrawable("slider-fancy-knob").tint(skin.getColor("selection"));
    tiledDrawable.setMinWidth(0);
    progressBarStyle.knobBefore = tiledDrawable;

    sliderStyle = skin.get("fancy", Slider.SliderStyle.class);
    sliderStyle.knobBefore = tiledDrawable;

    layoutTable = new Table();
    layoutTable.top();
    layoutTable.setFillParent(true);
    layoutTable.pad(getPixelSizeFromDensityIndependentPixels(50));
}
 
Example 12
Project: Hexpert   File: TileEffectDialog.java   View source code 6 votes vote down vote up
public TileEffectDialog(Hexpert hexpert, Skin skin) {
    super(hexpert, skin, false);
    getContentTable().defaults().pad(15);

    for(int i = 0; i < TileType.values().length; i++)
    {
        TileType tileType = TileType.values()[i];
        Image tileImage = new Image(new TextureRegion((Texture) hexpert.assetManager.get(SPRITE_FOLDER + tileType.name().toLowerCase() + "_tile.png")));
        getContentTable().add(tileImage).width(96).height(96);

        Label lblDesc = new Label(hexpert.i18NBundle.get(tileType.name().toLowerCase() + "_effect"), skin);
        lblDesc.setAlignment(Align.center);
        getContentTable().add(lblDesc);
        getContentTable().row();
    }
}
 
Example 13
Project: Polymorph   File: DeathScreen.java   View source code 6 votes vote down vote up
public void initButtons(int score,TextureAtlas buttonAtlas) {
    Skin buttonSkin = new Skin();
    buttonSkin.addRegions(buttonAtlas);

    //TODO FIX THIS SHIT INDENTATION
    //TODO Long-term fix the magic numbers
    ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"),
    		                                                        buttonSkin.getDrawable("playbutton"));
    playButton.setSize(256, 64);
    playButton.setPosition(screenSize.width/2-playButton.getWidth()/2,
    		               screenSize.height/2-playButton.getHeight()/2+50);
    playButton.addListener(new InputListener() {

    	@Override
    	public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
    		polymorph.setScreen(new GameScreen(polymorph));
    		DeathScreenMusic.stop();
    		return true;
    	}
    });

    stage.addActor(playButton);

}
 
Example 14
Project: MMORPG_Prototype   File: StringValueLabel.java   View source code 6 votes vote down vote up
public StringValueLabel(CharSequence text, Skin skin, T value)
{
	super(text, skin);
	this.value = value;
	originalText = text.toString();
	update();
}
 
Example 15
Project: bobbybird   File: Core.java   View source code 6 votes vote down vote up
public void loadAssets() {
    assetManager.clear();
    
    assetManager.load(DATA_PATH + "/skin/skin.json", Skin.class);
    
    for (String directory : imagePacks.keys()) {
        FileHandle folder = Gdx.files.local(directory);
        for (FileHandle file : folder.list()) {
            assetManager.load(file.path(), Pixmap.class);
            imagePacks.get(directory).add(file.nameWithoutExtension());
        }
    }
    
    assetManager.load(DATA_PATH + "/gfx/white.png", Pixmap.class);
    
    assetManager.load(DATA_PATH + "/sfx/coin.wav", Sound.class);
    assetManager.load(DATA_PATH + "/sfx/hit.wav", Sound.class);
    assetManager.load(DATA_PATH + "/sfx/jump.wav", Sound.class);
}
 
Example 16
Project: FlappySpinner   File: GameButton.java   View source code 6 votes vote down vote up
public GameButton(float WIDTH, float HEIGHT, String drawable, boolean isCheckable) {
    audioManager = AudioManager.getInstance();
    skin = new Skin();
    skin.addRegions(AssetsManager.getTextureAtlas());

    Button.ButtonStyle buttonStyle = new Button.ButtonStyle();
    buttonStyle.up = skin.getDrawable(drawable);
    buttonStyle.down = skin.getDrawable(drawable + "_pressed");
    if (isCheckable) {
        buttonStyle.checked = skin.getDrawable(drawable + "_pressed");
    }
    setStyle(buttonStyle);
    setSize(WIDTH, HEIGHT);

    rectangle = new Rectangle(getX(),getY(),getWidth(),getHeight());
    addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            audioManager.playSound(audioManager.getButtonSound());
        }
    });
}
 
Example 17
Project: Hexpert   File: ObjectiveDialog.java   View source code 6 votes vote down vote up
public ObjectiveDialog(Skin skin, Hexpert hexpert) {
    super(hexpert, skin);
    getBackground().setMinWidth(1000);

    final TextButton textButtonOK = new TextButton(hexpert.i18NBundle.get("ok"), skin);

    textButtonOK.addListener(new ClickListener(){

        @Override
        public void clicked(InputEvent event, float x, float y) {
            textButtonOK.setChecked(false);
        }
    });
    setObject(textButtonOK, null);
    getButtonTable().add(textButtonOK);

    getContentTable().defaults().pad(5, 0, 5, 15);
    getContentTable().top();
}
 
Example 18
Project: ExamensArbeteTD   File: LeftSection.java   View source code 6 votes vote down vote up
public LeftSection(Skin skin) {
	this.setSkin(skin);
	
       Table moneyStatPanel = new StatPanel(skin);
       Image coin = new Image(skin , "coin");
       moneyLabel = new Label("",skin , "fontHemi20" , "white");
       moneyStatPanel.add(coin).pad(5).align(Align.left).expand().size(23 , 21);
       moneyStatPanel.add(moneyLabel).align(Align.right).pad(5 , 5 , 5 ,10).expand();
       this.add(moneyStatPanel).align(Align.right).size(120 , 30).spaceBottom(2).row();
       Table grayPanel = new GrayPanel(skin);
       _laserTowerIcon = new Image(skin , "laser-tower-icon");
       _plastmaTowerIcon = new Image(skin , "plastma-tower-icon");
       _missleTurretIcon = new Image(skin,"missile-tower-icon");
       
       _laserTowerTooltipTable = new LaserTowerTooltipTable(skin, TowerType.BASIC_LASER_TURRET);
       _plastmaTowerTooltipTable = new PlastmaTowerTooltipTable(skin, TowerType.PLASTMA_TOWER);
       _missileTowerTooltipTable = new MissileTowerTooltipTable(skin, TowerType.MISSILE_TURRET);
       
       _laserTowerIcon.addListener(_laserTowerTooltipTable.getTooltip());
       _plastmaTowerIcon.addListener(_plastmaTowerTooltipTable.getTooltip());
       _missleTurretIcon.addListener(_missileTowerTooltipTable.getTooltip());
       grayPanel.add(_laserTowerIcon).size(32,32).pad(10).align(Align.topLeft);
       grayPanel.add(_plastmaTowerIcon).size(32,32).pad(10).align(Align.topLeft);
       grayPanel.add(_missleTurretIcon).size(32, 32).pad(10).align(Align.topLeft).expand(32,32);
       this.add(grayPanel).expand();
}
 
Example 19
Project: ExamensArbeteTD   File: PauseWindow.java   View source code 6 votes vote down vote up
public PauseWindow(String title, Skin skin) {
	super(title, skin);
       this.setVisible(false);
       primaryMenu = new Table(skin);
       settingsPanel = new SettingsPanel(skin);
       _okButton  = new TextButton("OK" , skin , "menu");
       settingsPanel.add(_okButton);
       _resumeButton = new TextButton("Resume",Assets._skin , "menu");
       _mainMenuButton = new TextButton("Main Menu",Assets._skin , "menu");
       _settingsButton = new TextButton("Settings",Assets._skin , "menu");
       
       primaryMenu.add(_resumeButton).padBottom(20f).row();
       primaryMenu.add(_settingsButton).padBottom(20f).row();
       primaryMenu.add(_mainMenuButton);
       this.add(primaryMenu).align(Align.center).fill();
}
 
Example 20
Project: cocos2d-java   File: GdxUISkin.java   View source code 5 votes vote down vote up
public Skin getSkin(String path) {
	for(int i = 0; i < skins.size; ++i) {
		StructSkin ss = skins.get(i);
		if(path.equals(ss.first)) {
			return ss.second;
		}
	}
	return null;
}
 
Example 21
Project: cocos2d-java   File: GdxUIConsole.java   View source code 5 votes vote down vote up
@Override
protected void onInitUI() {
	Skin skin = GdxUISkin.instance().getDeafult();
	input = new TextField("", skin);
	
	ClickListener mClickListener = new ClickListener() {
		public boolean keyDown (InputEvent event, int keycode) {
			if(keycode == Keys.ENTER && !isHide()) {
				if(!handleCmdString(input.getText())) {
					//clear input 
					input.setText(null);
				}
			}
			return true;
		}
	};
	input.addCaptureListener(mClickListener);
	
	input.setTextFieldFilter(new TextFieldFilter() {
		@Override
		public boolean acceptChar(TextField textField, char c) {
			if(c == '`' || c == '~') {
				hide();
				return false;
			}
			return true;
		}
	});
	label = new Label("", skin);
	
	maxTmp = GdxUIConfig.instance().consoleMaxOutputLine;
	
	input.setSize(getUIWidth()/2, 32);
	input.setPosition(20, getUIHeight() * 0.25f);
	addUI(input);
	addUI(label);
	
	skin = null;
}
 
Example 22
Project: Catan   File: CatanWindow.java   View source code 5 votes vote down vote up
/**
 * Create a new window
 *
 * @param title the title of the window - must not be null
 * @param skin  skin used for theming the window
 */
public CatanWindow(String title, Skin skin) {
    super(title, skin, title.isEmpty() ? "no-title" : "default");
    width = 3f / 4f * Gdx.graphics.getWidth();
    height = 3f / 4f * Gdx.graphics.getHeight();
    init();
}
 
Example 23
Project: feup-lpoo-armadillo   File: Armadillo.java   View source code 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void create() {
    batch = new SpriteBatch();
    assetManager = new AssetManager();

    skin1 = new Skin(Gdx.files.internal("appearance/Armadillo.json"), new TextureAtlas("appearance/Armadillo.atlas"));
    skin2 = new Skin(Gdx.files.internal("appearance/smallBtn.json"), new TextureAtlas("appearance/smallBtn.atlas"));

    loadAssets();
    setMusic();
    startGame();
}
 
Example 24
Project: Hexpert   File: FreeridingDialog.java   View source code 5 votes vote down vote up
public FreeridingDialog(final Hexpert hexpert, Skin skin)
{
    super(hexpert, skin.get("gold", WindowStyle.class));

    getBackground().setMinWidth(1400);
    I18NBundle i18N = hexpert.i18NBundle;
    Label lblRate = new Label(i18N.get("freerider"), skin.get("bigger", Label.LabelStyle.class));
    lblRate.setAlignment(Align.center);
    lblRate.setWrap(true);
    getContentTable().add(lblRate).width(1200);

    TextButton.TextButtonStyle goldenStyle = skin.get("gold", TextButton.TextButtonStyle.class);


    TextButton textButtonRate = new TextButton(i18N.get("rate"), goldenStyle);
    getButtonTable().add(textButtonRate).width(textButtonRate.getLabelCell().getPrefWidth() + 30);


    TextButton textButtonNo = new TextButton(i18N.get("no"), goldenStyle);
    getButtonTable().add(textButtonNo);
    setObject(textButtonNo, null);

    textButtonRate.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            hexpert.playServices.rateGame();
            hide();
        }
    });

    setObject(textButtonRate, null);
}
 
Example 25
Project: conquest   File: NumberField.java   View source code 5 votes vote down vote up
NumberField(String text, Skin skin) {
    super(text, skin);
    setSize(115, 40);
    setPosition(Gdx.graphics.getWidth() / 3 - getWidth() / 2, Gdx.graphics.getHeight() / 2 + getHeight() / 4);
    setAlignment(Align.center);
    setTextFieldFilter(new TextFieldFilter.DigitsOnlyFilter());
}
 
Example 26
Project: blueirisviewer   File: UIElement.java   View source code 5 votes vote down vote up
public UIElement(Skin skin)
{
	UI.uiElements.add(this);
	parent = new Table();
	parent.setFillParent(true);
	window = new Window("Unnamed Window", skin);
	window.setModal(BlueIrisViewer.bivSettings.modalUI);
	table = new Table(skin);
	window.add(table);

	hide();

	parent.add(window);
	onCreate(skin, window, table);
}
 
Example 27
Project: GDX-Engine   File: UIManager.java   View source code 5 votes vote down vote up
public UIManager(String title, Skin skin,IGameService service) {
	super();
	
	mainMenu = new Window(title, skin);
	addActor(mainMenu);
	
	this.components = getRoot();
	this.batch = getSpriteBatch();
	
	this.service = service;
}
 
Example 28
Project: GDX-Engine   File: GuiManager.java   View source code 5 votes vote down vote up
public GuiManager(Skin skin, UIManager manager) {
super();

buildTowerGUI = new BuildTowerGUI(skin);
add("buildTower", buildTowerGUI);
buildWeaponGUI = new BuildWeaponGUI(skin);
add("addWeapon", buildWeaponGUI);

editTowerGUI = new EditWeaponGUI(skin);
add("editWeapon", editTowerGUI);

manager.addActor(buildWeaponGUI);
manager.addActor(buildTowerGUI);
manager.addActor(editTowerGUI);
   }
 
Example 29
Project: GDX-Engine   File: BuildTowerGUI.java   View source code 5 votes vote down vote up
@Override
   protected void onBuild(Skin skin) {
btnAddTower = new TextButton("",skin);
btnAddTower.setText("Add Tower ($100)");
row().fill().expandX();
add(btnAddTower).expandX();
super.onBuild(skin);
   }
 
Example 30
Project: SpaceChaos   File: SkinFactory.java   View source code 5 votes vote down vote up
public static Skin createSkin(final String jsonFile) {
    Skin skin = new Skin(Gdx.files.absolute(jsonFile));
    skin.getAtlas().getTextures().iterator().next().setFilter(Texture.TextureFilter.Nearest,
            Texture.TextureFilter.Nearest);
    skin.getFont("default-font").getData().markupEnabled = true;
    float scale = 1;
    skin.getFont("default-font").getData().setScale(scale);

    return skin;
}
 
Example 31
Project: CursedEcho   File: CursedEchoController.java   View source code 5 votes vote down vote up
private void initTouchPad() {
	touchpadSkin = new Skin();
	touchpadSkin.add("touchBackground", GameUtils.getGame().assetHandler.get("Controls/touchBackground.png",Texture.class));
	touchpadSkin.add("touchKnob", GameUtils.getGame().assetHandler.get("Controls/touchKnob.png",Texture.class));
	touchpadStyle = new TouchpadStyle();
	touchBackground = touchpadSkin.getDrawable("touchBackground");
	touchKnob = touchpadSkin.getDrawable("touchKnob");
	touchpadStyle.background = touchBackground;
	touchpadStyle.knob = touchKnob;
	touchpad = new Touchpad(10, touchpadStyle);
	touchpad.setBounds(15, 15, 200, 200);
	
}
 
Example 32
Project: gdx-cclibs   File: ExampleRunner.java   View source code 5 votes vote down vote up
@Override
public void create() {
    spriteBatch = new SpriteBatch();
    stage = new Stage(new ScreenViewport());
    skin = new Skin(Gdx.files.internal("uiskin.json"));
    Table table = new Table(skin);
    table.setFillParent(true);
    selectBox = new SelectBox<Class<? extends Example>>(skin){
        protected String toString (Class<? extends Example> obj) {
            return obj.getSimpleName();
        }
    };
    selectBox.setItems(examples);
    table.add(selectBox).fillX().space(20).row();
    stage.addActor(table);
    TextButton startButton = new TextButton("Start example", skin);
    startButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            runSelectedExample();
        }
    });
    table.add(startButton).fillX();

    if (arg != null && arg.length > 0) {
        Class<? extends Example> specifiedExample = getExample(arg[0]);
        if (specifiedExample != null){
            startExample(specifiedExample);
            return;
        }
    }

    setScreen(menuScreen);
}
 
Example 33
Project: gdx-cclibs   File: FlexBatchTest.java   View source code 5 votes vote down vote up
private void setupUI() {
	stage = new Stage(new ScreenViewport(), quad2dBatch);
	skin = new Skin(Gdx.files.internal("uiskin.json"));

	final SelectBox<Test> selectBox = new SelectBox<Test>(skin);
	selectBox.setItems(Test.values());
	selectBox.addListener(new ChangeListener() {
		public void changed(ChangeEvent event, Actor actor) {
			test = selectBox.getSelected();
			elapsed = 0;
		}
	});
	Table table = new Table();
	table.setFillParent(true);
	table.defaults().padTop(5).left();
	table.top().left().padLeft(5);
	table.add(selectBox).row();
	table.add(new Label("", skin) {
		int fps = -1;

		public void act(float delta) {
			super.act(delta);
			if (Gdx.graphics.getFramesPerSecond() != fps) {
				fps = Gdx.graphics.getFramesPerSecond();
				setText("" + fps);
			}
		}
	}).row();
	stage.addActor(table);
}
 
Example 34
Project: Particles   File: IntroScreen.java   View source code 5 votes vote down vote up
IntroScreen(final ParticleGame game) {
    particle_game = game;
    stage = new Stage();
    table = new Table();

    table.setFillParent(true);
    table.setDebug(true);
    stage.addActor(table);

    Skin skin = new Skin();
    
    Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    
    skin.add("white", new Texture(pixmap));
    skin.add("font", game.getFont());

    TextButton.TextButtonStyle text_button_style = new TextButton.TextButtonStyle();
    final Color button_color = new Color(226 / 255f, 226 / 255f, 226 / 255f, 1f);
    final Color hover_color = new Color(162 / 255f, 162 / 255f, 162 / 255f, 1f);
    text_button_style.up = skin.newDrawable("white", button_color);
    text_button_style.down = skin.newDrawable("white", button_color);
    text_button_style.over = skin.newDrawable("white", hover_color);
    text_button_style.font = skin.getFont("font");
    skin.add("default", text_button_style);

    TextButton play_button = new TextButton("play", skin);
    play_button.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            particle_game.setScreen(particle_game.getGameSetupScreen());
        }
    });
    table.add(play_button);
}
 
Example 35
Project: Particles   File: ParticleChoiceScreen.java   View source code 5 votes vote down vote up
ParticleChoiceScreen(final ParticleGame p, final GameScreen g) {
    game = p;
    game_screen = g;

    camera = new OrthographicCamera(PARTICLE_BOARD_W, PARTICLE_BOARD_W);
    camera.position.set(PARTICLE_BOARD_W / 2, PARTICLE_BOARD_W / 2, 0);
    camera.update();

    initStage();
    initTable();

    Skin skin = new Skin();

    Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add("white", new Texture(pixmap));
    skin.add("default", game.getFont());

    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    final Color buttonColor = new Color(226 / 255f, 226 / 255f, 226 / 255f, 1f);
    final Color hoverColor = new Color(162 / 255f, 162 / 255f, 162 / 255f, 1f);
    textButtonStyle.up = skin.newDrawable("white", buttonColor);
    textButtonStyle.down = skin.newDrawable("white", buttonColor);
    textButtonStyle.over = skin.newDrawable("white", hoverColor);
    textButtonStyle.font = skin.getFont("default");
    skin.add("default", textButtonStyle);

    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.getFont();
    labelStyle.fontColor = Color.WHITE;
    skin.add("default", labelStyle);

    // initTableContents(skin);
}
 
Example 36
Project: MMORPG_Prototype   File: Assets.java   View source code 5 votes vote down vote up
public static void dispose()
{
	assets.dispose();
	font.dispose();
	stages.clear();
	batch.dispose();
	for (Skin skin : skins.values())
		skin.dispose();
}
 
Example 37
Project: fluffybalance   File: BalanceBallSec.java   View source code 5 votes vote down vote up
private void initGuiResources() {
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("kenvector_future.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = (int) (16.f * Gdx.graphics.getDensity());
    mFont = generator.generateFont(parameter);
    generator.dispose();

    mSkin = new Skin(Gdx.files.internal("skin/flat-earth-ui.json"));
}
 
Example 38
Project: retro-reversi   File: Reversi.java   View source code 5 votes vote down vote up
@Override
public void create () {
	batch = new SpriteBatch();
       assetManager = new AssetManager();
	viewport = new ExtendViewport(512, 854);

       atlas = new TextureAtlas("retro-normal-font/retro-normal-font.atlas");
       skin = new Skin(Gdx.files.internal("retro-normal-font/retro-normal-font.json"), atlas);
	loadAssets();

       playServices.signIn();
	setScreen(new MainMenuView(this));
}
 
Example 39
Project: bobbybird   File: MenuState.java   View source code 5 votes vote down vote up
@Override
public void start() {
    skin = getCore().getAssetManager().get(Core.DATA_PATH + "/skin/skin.json", Skin.class);
    stage = new Stage(new ScreenViewport());
    
    Gdx.input.setInputProcessor(stage);
    
    Image bg = new Image(skin, "sky");
    bg.setFillParent(true);
    stage.addActor(bg);
    
    createBG();
    
    createMenu();
}
 
Example 40
Project: bobbybird   File: LoadingState.java   View source code 5 votes vote down vote up
private Skin createSkin() {
    Skin returnValue = new Skin();
    
    returnValue.add("bg", createDrawable(20, 20, Color.DARK_GRAY), Drawable.class);
    returnValue.add("progress-bar-back", createDrawable(20, 20, Color.BLACK), Drawable.class);
    returnValue.add("progress-bar", createDrawable(1, 20, Color.BLUE), Drawable.class);
    
    ProgressBarStyle progressBarStyle = new ProgressBarStyle();
    progressBarStyle.background = returnValue.getDrawable("progress-bar-back");
    progressBarStyle.knobBefore = returnValue.getDrawable("progress-bar");
    
    returnValue.add("default-horizontal", progressBarStyle);
    
    return returnValue;
}