com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable. 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: SceneTheme.java    From Radix with MIT License 5 votes vote down vote up
public void init() {
    this.labelFont = new BitmapFont();

    this.buttonBgTex = new Texture(Gdx.files.internal("textures/gui/guiButtonBackground.png"));
    this.buttonBgPressTex = new Texture(Gdx.files.internal("textures/gui/guiButtonBackground-pressed.png"));
    this.buttonBgDisabledTex = new Texture(Gdx.files.internal("textures/gui/guiButtonBackground-disabled.png"));

    SpriteDrawable buttonBgSprite = new SpriteDrawable(new Sprite(buttonBgTex));
    SpriteDrawable buttonBgPressSprite = new SpriteDrawable(new Sprite(buttonBgPressTex));
    SpriteDrawable buttonBgDisabledSprite =new SpriteDrawable(new Sprite(buttonBgDisabledTex));
    this.buttonStyle = new ImageTextButtonStyle(buttonBgSprite, buttonBgPressSprite, buttonBgDisabledSprite, labelFont);
}
 
Example #2
Source File: Skin.java    From gdx-skineditor with Apache License 2.0 5 votes vote down vote up
/** Returns a copy of the specified drawable. */
public Drawable newDrawable(Drawable drawable) {
	if (drawable instanceof TextureRegionDrawable)
		return new TextureRegionDrawable((TextureRegionDrawable) drawable);
	if (drawable instanceof NinePatchDrawable)
		return new NinePatchDrawable((NinePatchDrawable) drawable);
	if (drawable instanceof SpriteDrawable)
		return new SpriteDrawable((SpriteDrawable) drawable);
	throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass());
}
 
Example #3
Source File: CardDeckApplication.java    From androidsvgdrawable-plugin with Apache License 2.0 5 votes vote down vote up
private void initializeAssets() {
    skin = manager.get("skin.json", Skin.class);
    atlas = manager.get("skin.atlas", TextureAtlas.class);

    // layout
    Table table = new Table();
    table.pad(10);
    table.defaults().space(10);
    table.setFillParent(true);

    // header
    table.row();
    table.add(new Label("LibGDX Card Deck", skin, "cantarell")).colspan(RANKS.length);

    // deck
    for (String suit : SUITS) {
        table.row();
        for (String rank : RANKS) {
            table.add(
                    new Image(
                            new SpriteDrawable(atlas.createSprite(String.format("card1_suit_%s_rank_%s", suit, rank))),
                            Scaling.fit));
        }
    }

    stage.addActor(table);
}
 
Example #4
Source File: SMGUIManager.java    From Entitas-Java with MIT License 4 votes vote down vote up
public Skin createSkin(BaseAssetsManager assetsManager) {
    defaultFont = assetsManager.getFont(DEFAULT_FONT);
    defaultFont.getData().setScale(ScaleUtil.getSizeRatio());
    defaultFont.setUseIntegerPositions(false);
    font2 = assetsManager.getFont(HEADER_FONT);
    font2.getData().setScale(ScaleUtil.getSizeRatio());
    font2.setUseIntegerPositions(false);

    skin.add("default", defaultFont);
    skin.add("header", font2);

    skin.add("lt-blue", new Color(.62f, .76f, .99f, 1f));
    skin.add("lt-green", new Color(.39f, .9f, .6f, 1f));
    skin.add("dark-blue", new Color(.79f, .95f, 91f, 1f));

    skin.addRegions(assetsManager.getTextureAtlas(GUI_ATLAS));
    skin.addRegions(assetsManager.getTextureAtlas(GUI_PACK_ATLAS));


    TextureRegionDrawable touchpad_background = new TextureRegionDrawable(((TextureAtlas) assetsManager.getTextureAtlas(GUI_ATLAS)).findRegion("touchpad_background"));
    TextureRegionDrawable touchpad_thumb = new TextureRegionDrawable(((TextureAtlas) assetsManager.getTextureAtlas(GUI_ATLAS)).findRegion("touchpad_thumb"));


    TextureRegionDrawable checkox_true = new TextureRegionDrawable(((TextureAtlas) assetsManager.getTextureAtlas(UISKIN_ATLAS)).findRegion("check-on"));

    TextureRegionDrawable checkox_false = new TextureRegionDrawable(((TextureAtlas) assetsManager.getTextureAtlas(UISKIN_ATLAS)).findRegion("check-off"));

    TextureRegionDrawable slider_knob = new TextureRegionDrawable(((TextureAtlas) assetsManager.getTextureAtlas(UISKIN_ATLAS)).findRegion("default-slider-knob"));
    TextureRegionDrawable slider = new TextureRegionDrawable(((TextureAtlas) assetsManager.getTextureAtlas(UISKIN_ATLAS)).findRegion("default-slider"));

    CheckBox.CheckBoxStyle checkBoxStyle = new CheckBox.CheckBoxStyle(checkox_false, checkox_true, defaultFont, Color.WHITE);


    SpriteDrawable stats = new SpriteDrawable(new Sprite((Texture) assetsManager.getTexture(STATS_BACKGROUND)));


    Slider.SliderStyle sliderStyle = new Slider.SliderStyle(slider, slider_knob);
    skin.add("default", new Window.WindowStyle(font2, Color.ORANGE, skin.getDrawable("debug")));
    skin.add("stats", stats);


    Label.LabelStyle lbs = new Label.LabelStyle();
    lbs.font = defaultFont;
    lbs.fontColor = Color.WHITE;
    skin.add("default", lbs);

    Label.LabelStyle lbsHeader = new Label.LabelStyle();
    lbsHeader.font = font2;
    lbsHeader.fontColor = Color.WHITE;
    skin.add("header", lbsHeader);

    TextButton.TextButtonStyle tbs = new TextButton.TextButtonStyle(skin.getDrawable("btnMenu"), skin.getDrawable("btnMenuPress"), skin.getDrawable("btnMenu"), defaultFont);
    tbs.fontColor = skin.getColor("dark-blue");
    tbs.pressedOffsetX = Math.round(1f * Gdx.graphics.getDensity());
    tbs.pressedOffsetY = tbs.pressedOffsetX * -1f;

    ImageButton.ImageButtonStyle ImageButtonLeft = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonLeft"), skin.getDrawable("buttonLeftPress"),
            skin.getDrawable("buttonLeft"), null, null, null);
    ImageButton.ImageButtonStyle ImageButtonRight = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonRight"), skin.getDrawable("buttonRightPress"),
            skin.getDrawable("buttonRight"), null, null, null);
    ImageButton.ImageButtonStyle ImageButtonUp = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonUp"), skin.getDrawable("buttonUpPress"),
            skin.getDrawable("buttonUp"), null, null, null);


    Touchpad.TouchpadStyle touchpadStyle = new Touchpad.TouchpadStyle();
    touchpadStyle.background = touchpad_background;
    touchpadStyle.knob = touchpad_thumb;


    skin.add("default", tbs);
    skin.add("buttonLeft", ImageButtonLeft);
    skin.add("buttonRight", ImageButtonRight);
    skin.add("buttonUp", ImageButtonUp);
    skin.add("default", touchpadStyle);
    skin.add("default", checkBoxStyle);
    skin.add("default-horizontal", sliderStyle);

    return skin;
}