Search in sources :

Example 16 with Sprite

use of com.badlogic.gdx.graphics.g2d.Sprite in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnNotAliasWhenAtlasRegionsAreNotEqual.

@Test
public void shouldReturnNotAliasWhenAtlasRegionsAreNotEqual() {
    Sprite sprite1 = new AtlasSprite(new AtlasRegion(texture512x512, 50, 30, 40, 40));
    Sprite sprite2 = new AtlasSprite(new AtlasRegion(texture512x512, 50, 30, 20, 40));
    assertFalse(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
Also used : AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) AtlasRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion) Test(org.junit.Test)

Example 17 with Sprite

use of com.badlogic.gdx.graphics.g2d.Sprite in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnIsAliasWhenRegionEquals.

@Test
public void shouldReturnIsAliasWhenRegionEquals() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    TextureRegion region2 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    Sprite sprite1 = new Sprite(region1);
    Sprite sprite2 = new Sprite(region2);
    assertTrue(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Test(org.junit.Test)

Example 18 with Sprite

use of com.badlogic.gdx.graphics.g2d.Sprite in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnFalseIfSpriteNull.

@Test
public void shouldReturnFalseIfSpriteNull() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    Sprite sprite1 = new Sprite(region1);
    assertFalse(SpriteUtils.isAliasSprite(sprite1, null));
    assertFalse(SpriteUtils.isAliasSprite(null, sprite1));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Test(org.junit.Test)

Example 19 with Sprite

use of com.badlogic.gdx.graphics.g2d.Sprite in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnAliasWhenAtlasRegionsAreEqual.

@Test
public void shouldReturnAliasWhenAtlasRegionsAreEqual() {
    AtlasRegion atlasRegion1 = new AtlasRegion(texture512x512, 50, 30, 40, 40);
    AtlasRegion atlasRegion2 = new AtlasRegion(texture512x512, 50, 30, 40, 40);
    Sprite sprite1 = new AtlasSprite(atlasRegion1);
    Sprite sprite2 = new AtlasSprite(atlasRegion2);
    assertTrue(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
Also used : AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) AtlasRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion) Test(org.junit.Test)

Example 20 with Sprite

use of com.badlogic.gdx.graphics.g2d.Sprite in project Entitas-Java by Rubentxu.

the class SMGUIManager method createSkin.

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;
}
Also used : TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texture(com.badlogic.gdx.graphics.Texture) SpriteDrawable(com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Color(com.badlogic.gdx.graphics.Color)

Aggregations

Sprite (com.badlogic.gdx.graphics.g2d.Sprite)40 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)19 Texture (com.badlogic.gdx.graphics.Texture)17 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)13 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)11 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)10 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)8 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)8 Test (org.junit.Test)8 SpriteDrawable (com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable)7 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)6 Pixmap (com.badlogic.gdx.graphics.Pixmap)5 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)4 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)4 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)4 InputAdapter (com.badlogic.gdx.InputAdapter)3 Matrix4 (com.badlogic.gdx.math.Matrix4)3 Vector2 (com.badlogic.gdx.math.Vector2)3 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)3 NinePatchDrawable (com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable)3