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; }
public Drawable findDrawable(ObjectData option, String name) { if (option.isScale9Enable()) {// 九宫格支持 TextureRegion textureRegion = findTextureRegion(option, name); NinePatch np = new NinePatch(textureRegion, option.getScale9OriginX(), textureRegion.getRegionWidth() - option.getScale9Width() - option.getScale9OriginX(), option.getScale9OriginY(), textureRegion.getRegionHeight() - option.getScale9Height() - option.getScale9OriginY()); np.setColor(getColor(option.getCColor(), option.getAlpha())); return new NinePatchDrawable(np); } TextureRegion tr = findTextureRegion(option, name); if (tr == null) { return null; } return new TextureRegionDrawable(tr); }
private void addWindowStyles() { final Color backgroundColor = new Color(0, 0.3f, 0.6f, 1f); final Color borderColor = new Color(backgroundColor).lerp(Color.WHITE, 0.2f); final int borderBorder = 4; final int borderWidth = 4; final int pixmapSize = 2 * (borderBorder + borderWidth) + 1; Pixmap windowBackground = new Pixmap(pixmapSize, pixmapSize, Pixmap.Format.RGBA8888); windowBackground.setColor(backgroundColor); windowBackground.fill(); windowBackground.setColor(borderColor); windowBackground.fillRectangle(borderBorder, borderBorder, pixmapSize - 2 * borderBorder, pixmapSize - 2 * borderBorder); windowBackground.setColor(backgroundColor); windowBackground.fillRectangle(borderBorder + borderWidth, borderBorder + borderWidth, pixmapSize - 2 * (borderBorder + borderWidth), pixmapSize - 2 * (borderBorder + borderWidth)); Texture backgroundWindow = new Texture(windowBackground); NinePatch backgroundPatch = new NinePatch(backgroundWindow, borderBorder + borderWidth, borderBorder + borderWidth, borderBorder + borderWidth, borderBorder + borderWidth); Drawable background = new NinePatchDrawable(backgroundPatch); BitmapFont font = get("normal", BitmapFont.class); WindowStyle window = new WindowStyle(font, Color.WHITE, background); add("default", window); }
public Button(String text, float x, float y, int key) { font = new BitmapFont(); layout = new GlyphLayout(); this.key = key; this.text = text; setX(x); setY(y); layout.setText(font, text); setWidth((2 * offset) + layout.width); setHeight(11 + (2 * offset)); np = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np.png")), 16, 16, 16, 16); np_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_hover.png")), 16, 16, 16, 16); np_checked = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked.png")), 16, 16, 16, 16); np_checked_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked_hover.png")), 16, 16, 16, 16); checkbox = false; checked = false; }
public Button(String text, float x, float y) { font = new BitmapFont(); layout = new GlyphLayout(); this.text = text; setX(x); setY(y); key = -1; layout.setText(font, text); setWidth((2 * offset) + layout.width); setHeight(11 + (2 * offset)); np = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np.png")), 16, 16, 16, 16); np_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_hover.png")), 16, 16, 16, 16); np_checked = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked.png")), 16, 16, 16, 16); np_checked_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked_hover.png")), 16, 16, 16, 16); checkbox = false; checked = false; }
public TilePanel( Skin skin, Stage stage, Sprite tileBackground, Sprite tileBorder, int viewWidth, int viewHeight, int tileSize, boolean expandVertically ) { this.skin = skin; this.stage = stage; this.tileBackground = tileBackground; this.tileBorder = tileBorder; this.targetWidth = viewWidth; this.targetHeight = viewHeight; this.viewWidth = viewWidth; this.viewHeight = viewHeight; this.tileSize = tileSize; this.expandVertically = expandVertically; this.tilePanelBackgroundH = new NinePatch( AssetManager.loadTextureRegion( "Sprites/GUI/PanelHorizontal.png" ), 21, 21, 21, 21 ); this.tilePanelBackgroundV = new NinePatch( AssetManager.loadTextureRegion( "Sprites/GUI/PanelVertical.png" ), 21, 21, 21, 21 ); TilePanelListener listener = new TilePanelListener(); this.addListener( listener ); this.setWidth( getPrefWidth() ); }
static NinePatch newMidlessPatch () { final int patchSize = 8; final int fullPatchHeight = patchSize * 2; final int fullPatchWidth = patchSize * 3; final int pixmapDim = MathUtils.nextPowerOfTwo(Math.max(fullPatchWidth, fullPatchHeight)); Pixmap testPatch = new Pixmap(pixmapDim, pixmapDim, Pixmap.Format.RGBA8888); testPatch.setColor(1, 1, 1, 0); testPatch.fill(); for (int x = 0; x < fullPatchWidth; x += patchSize) { for (int y = 0; y < fullPatchHeight; y += patchSize) { testPatch.setColor(x / (float)fullPatchWidth, y / (float)fullPatchHeight, 1.0f, 1.0f); testPatch.fillRectangle(x, y, patchSize, patchSize); } } return new NinePatch(new TextureRegion(new Texture(testPatch), fullPatchWidth, fullPatchHeight), patchSize, patchSize, patchSize, patchSize); }
public AudioControl(TextureAtlas hudAtlas) { super(new NinePatchDrawable(new NinePatch(hudAtlas.findRegion("audio-on"), WHITE)), new NinePatchDrawable(new NinePatch( hudAtlas.findRegion("audio-on"), ICS_BLUE)), new NinePatchDrawable(new NinePatch(hudAtlas.findRegion("audio-off"), WHITE))); layout(); GameSoundController.runAfterInit(new Runnable() { @Override public void run() { setChecked(!DroidTowersGame.getSoundController().isAudioState()); addListener(new VibrateClickListener() { public void onClick(InputEvent event, float x, float y) { DroidTowersGame.getSoundController().toggleAudio(); } }); } }); }
@Override public void create() { float hh = Gdx.graphics.getHeight() / 2f, hw = Gdx.graphics.getWidth() / 2f; this.wBar = hw * 1.5f; this.hBar = hw / 7f; this.xBar = hw - this.wBar / 2f; this.yBar = hh / 2f - hBar / 2f; this.atlas = new TextureAtlas("data/ninepatch/ninepatch.atlas"); this.loadingBar = new NinePatch(atlas.findRegion("2"), 4, 4, 4, 4); this.loadingProgress = new NinePatch(atlas.findRegion("3"), 4, 4, 4, 4); stage = new Stage(screenw,screenh, true); this.sb = stage.getSpriteBatch(); am = new AssetManager(); /*-QUEUE here loading assets-*/ am.load(SKIN_SRC, Skin.class); }
public void initMainMenu() { atlas = new TextureAtlas(Gdx.files.internal(TEXTURE_ATLAS_LOC)); checked = atlas.findRegion(CHECKED_REGION_STRING); unchecked = atlas.findRegion(UNCHECKED_REGION_STRING); background = atlas.findRegion(BACKGROUN_REGION_STRING); knob = atlas.findRegion(KNOB_REGION_STRING); titleSprite = atlas.createSprite(TITLE_REGION_STRING); levelOnePreviewRegion = new TextureRegion(atlas.findRegion(LEVEL_ONE_REGION_STRING)); levelTwoPreviewRegion = new TextureRegion(atlas.findRegion(LEVEL_TWO_REGION_STRING)); levelThreePreviewRegion = new TextureRegion(atlas.findRegion(LEVEL_THREE_REGION_STRING)); levelFourPreviewRegion = new TextureRegion(atlas.findRegion(LEVEL_FOUR_REGION_STRING)); levelFivePreviewRegion = new TextureRegion(atlas.findRegion(LEVEL_FIVE_REGION_STRING)); patchBox = new NinePatch(atlas.createPatch(PATCH_BOX_REGION_STRING)); finePrint = new BitmapFont(Gdx.files.internal(FINE_PRINT)); font = new BitmapFont(Gdx.files.internal(FONT_LOC)); }
public <T> T get(String name, Class<T> type) { if (name == null) throw new IllegalArgumentException("name cannot be null."); if (type == null) throw new IllegalArgumentException("type cannot be null."); if (type == Drawable.class) return (T) getDrawable(name); if (type == TextureRegion.class) return (T) getRegion(name); if (type == NinePatch.class) return (T) getPatch(name); if (type == Sprite.class) return (T) getSprite(name); ObjectMap<String, Object> typeResources = resources.get(type); if (typeResources == null) throw new GdxRuntimeException("No " + type.getName() + " registered with name: " + name); Object resource = typeResources.get(name); if (resource == null) throw new GdxRuntimeException("No " + type.getName() + " registered with name: " + name); return (T) resource; }
/** * Adds a tile to represent a ShipCoordinate. */ public void addTile( ShipCoordinate coord ) { if ( coord.v != 0 ) return; TextureAtlas floorAtlas = assetManager.get( OVDConstants.FLOORPLAN_ATLAS, TextureAtlas.class ); TextureRegion tileRegion = floorAtlas.findRegion( "floor-line" ); NinePatchDrawable tileDrawable = new NinePatchDrawable( new NinePatch( tileRegion, 1, 1, 1, 1 ) ); Image tileImage = new Image( tileDrawable ); tileImage.setPosition( calcTileX( coord ), calcTileY( coord ) ); tileImage.setSize( tileSize, tileSize ); tiles.add( tileImage ); // These are different floats which can cause gaps when mixed. // (x * size + size) != ((x+1) * size) }
/** * Adds a tile to represent a ShipCoordinate. */ public void addTile( ShipCoordinate coord ) { if ( coord.v != 0 ) return; TextureAtlas floorAtlas = assetManager.get( OVDConstants.FLOORPLAN_ATLAS, TextureAtlas.class ); TextureRegion tileRegion = floorAtlas.findRegion( "floor-tile" ); NinePatchDrawable tileDrawable = new NinePatchDrawable( new NinePatch( tileRegion, 1, 1, 1, 1 ) ); Image tileImage = new Image( tileDrawable ); tileImage.setPosition( calcTileX( coord ), calcTileY( coord ) ); tileImage.setSize( tileSize, tileSize ); this.addActor( tileImage ); // These are different floats which can cause gaps when mixed. // (x * size + size) != ((x+1) * size) }
private void textWindowDemo() { BitmapFont plotFont = context.getAssetManager().get( PLOT_FONT, BitmapFont.class ); String loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "; loremIpsum += "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; loremIpsum += "\n\nThis window is draggable."; rootAtlas = context.getAssetManager().get( ROOT_ATLAS, TextureAtlas.class ); TextureRegion plotDlgRegion = rootAtlas.findRegion( "box-text1" ); NinePatchDrawable plotDlgBgDrawable = new NinePatchDrawable( new NinePatch( plotDlgRegion, 20, 20, 35, 20 ) ); Window plotDlg = new Window( "", new Window.WindowStyle( plotFont, new Color( 1f, 1f, 1f, 1f ), plotDlgBgDrawable ) ); plotDlg.setKeepWithinStage( true ); plotDlg.setMovable( true ); plotDlg.setSize( 200, 250 ); plotDlg.setPosition( 765, 60 ); plotDlg.row().top().expand().fill(); Label plotLbl = new Label( loremIpsum, new Label.LabelStyle( plotFont, new Color( 1f, 1f, 1f, 1f ) ) ); plotLbl.setAlignment( Align.top|Align.left, Align.center|Align.left ); plotLbl.setWrap( true ); plotDlg.add( plotLbl ); // setKeepWithinStage() only applies if added to the stage root. :/ popupStage.addActor( plotDlg ); }
public <T> T get(String paramString, Class<T> paramClass) { if (paramString == null) throw new IllegalArgumentException("name cannot be null."); if (paramClass == null) throw new IllegalArgumentException("type cannot be null."); Object localObject; if (paramClass == Drawable.class) localObject = getDrawable(paramString); do { return localObject; if (paramClass == TextureRegion.class) return getRegion(paramString); if (paramClass == NinePatch.class) return getPatch(paramString); if (paramClass == Sprite.class) return getSprite(paramString); ObjectMap localObjectMap = (ObjectMap)this.resources.get(paramClass); if (localObjectMap == null) throw new GdxRuntimeException("No " + paramClass.getName() + " registered with name: " + paramString); localObject = localObjectMap.get(paramString); } while (localObject != null); throw new GdxRuntimeException("No " + paramClass.getName() + " registered with name: " + paramString); }
public Sprite getSprite(String paramString) { Object localObject = (Sprite)optional(paramString, Sprite.class); if (localObject != null) return localObject; try { TextureRegion localTextureRegion = getRegion(paramString); if ((localTextureRegion instanceof TextureAtlas.AtlasRegion)) { TextureAtlas.AtlasRegion localAtlasRegion = (TextureAtlas.AtlasRegion)localTextureRegion; if ((localAtlasRegion.rotate) || (localAtlasRegion.packedWidth != localAtlasRegion.originalWidth) || (localAtlasRegion.packedHeight != localAtlasRegion.originalHeight)) localObject = new TextureAtlas.AtlasSprite(localAtlasRegion); } if (localObject == null) localObject = new Sprite(localTextureRegion); add(paramString, localObject, NinePatch.class); return localObject; } catch (GdxRuntimeException localGdxRuntimeException) { } throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + paramString); }
public Drawable newDrawable(String paramString, Color paramColor) { Drawable localDrawable = getDrawable(paramString); if ((localDrawable instanceof TextureRegionDrawable)) { Sprite localSprite1 = new Sprite(((TextureRegionDrawable)localDrawable).getRegion()); localSprite1.setColor(paramColor); return new SpriteDrawable(localSprite1); } if ((localDrawable instanceof NinePatchDrawable)) { NinePatchDrawable localNinePatchDrawable = new NinePatchDrawable((NinePatchDrawable)localDrawable); localNinePatchDrawable.setPatch(new NinePatch(localNinePatchDrawable.getPatch(), paramColor)); return localNinePatchDrawable; } if ((localDrawable instanceof SpriteDrawable)) { SpriteDrawable localSpriteDrawable = new SpriteDrawable((SpriteDrawable)localDrawable); Sprite localSprite2 = new Sprite(localSpriteDrawable.getSprite()); localSprite2.setColor(paramColor); localSpriteDrawable.setSprite(localSprite2); return localSpriteDrawable; } throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + localDrawable.getClass()); }
public final void a(Skin paramSkin, Stage paramStage) { Label.LabelStyle localLabelStyle = (Label.LabelStyle)paramSkin.get("default", Label.LabelStyle.class); ProgressIndicator localProgressIndicator = new ProgressIndicator(paramSkin); ScrollLabel localScrollLabel = new ScrollLabel("Obtaining Fix on Portal...", localLabelStyle, (byte)0); localScrollLabel.addAction(a.a(localScrollLabel, 2.0F)); localProgressIndicator.a(true); this.a = new Table(); this.a.setBackground(new NinePatchDrawable(new NinePatch(paramSkin.getPatch("item-button-outline"), new Color(1.0F, 1.0F, 1.0F, 0.5F)))); this.a.add(localProgressIndicator).n().a(Integer.valueOf(17)).g(10.0F); this.a.add(localScrollLabel).n().a(Integer.valueOf(9)); this.a.setWidth(1.05F * this.a.getPrefWidth()); this.a.setHeight(this.a.getPrefHeight()); this.a.setX((paramStage.getWidth() - this.a.getWidth()) / 2.0F); this.a.setY((paramStage.getHeight() - this.a.getHeight()) / 2.0F); this.a.getColor().a = 0.0F; this.a.addAction(Actions.fadeIn(0.5F)); paramStage.addActor(this.a); }
public void update(TextureRegion region, int[] splits) { Gdx.app.log("app","update"); this.region = region; clear(); NinePatch horizontalPatch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); NinePatch verticalPatch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); NinePatch squarePatch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); float minSclH = getMinScale(horizontalPatch, horizontalWidth, horizontalHeight); float minSclV = getMinScale(verticalPatch, verticalWidth, verticalHeight); float minSclS = getMinScale(squarePatch, squareWidth, squareHeight); float minScl = Math.min(minSclH, minSclV); minScl = Math.min(minScl, minSclS); horizontal = fitNinePatch(horizontalPatch, horizontalWidth, horizontalHeight, minScl); addActor(horizontal); vertical = fitNinePatch(verticalPatch, verticalWidth, verticalHeight, minScl); addActor(vertical); square = fitNinePatch(squarePatch, squareWidth, squareHeight, minScl); addActor(square); horizontal.setY(getHeight() - horizontalHeight); vertical.setY(horizontal.getY() - verticalHeight - 5); square.setX(verticalWidth + 5); square.setY(vertical.getY()); }
private float getMinScale(NinePatch horizontalPatch, float width, float height) { float scaleX = width/horizontalPatch.getTotalWidth(); float scaleY = height/horizontalPatch.getTotalHeight(); float scl = Math.min(scaleX, scaleY); if(scl > 1f) scl = 1f; return scl; }
private Image fitNinePatch(NinePatch horizontalPatch, float width, float height, float scl) { horizontalPatch.scale(scl, scl); Image img = new Image(horizontalPatch); img.setScaleX(width / horizontalPatch.getTotalWidth()); img.setScaleY(height / horizontalPatch.getTotalHeight()); return img; }
private void initGuiInGame() { mGuiStage = new Stage(new ScreenViewport()); Table gameScore = new Table(); if (DEBUG_RENDERER) { gameScore.debug(); } float scorePanelWidth = Gdx.graphics.getWidth() * 0.8f; // 80 % of screen float scorePanelHeight = Gdx.graphics.getHeight() * 0.2f; // 20 % of screen gameScore.setWidth(scorePanelWidth); gameScore.setHeight(scorePanelHeight); gameScore.setY(Gdx.graphics.getHeight() - (scorePanelHeight + 30.f)); gameScore.setX((Gdx.graphics.getWidth() - scorePanelWidth) * 0.5f); gameScore.setBackground(new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("red_button13.png")), 24, 24, 24, 24))); gameScore.pad(32.f); Label scoreLabel = new Label("Score", new Label.LabelStyle( mDefaultFont, COLOR_FONT)); scoreLabel.setFontScale(1.2f); gameScore.add(scoreLabel).expand(); gameScore.row(); mScoreLabel = new Label("" + mPointTotal, new Label.LabelStyle( mDefaultFont, COLOR_FONT)); mScoreLabel.setFontScale(2.0f); gameScore.add(mScoreLabel).expand(); mGuiStage.addActor(gameScore); }
public void create() { Stage stage = new Stage(new ScreenViewport()); getComponentByType(GuiComponent.class).stage = stage; Table gameScore = new Table(); float scorePanelWidth = Gdx.graphics.getWidth() * 0.8f; // 80 % of screen float scorePanelHeight = Gdx.graphics.getHeight() * 0.2f; // 20 % of screen gameScore.setWidth(scorePanelWidth); gameScore.setHeight(scorePanelHeight); gameScore.setY(Gdx.graphics.getHeight() - (scorePanelHeight + 30.f)); gameScore.setX((Gdx.graphics.getWidth() - scorePanelWidth) * 0.5f); gameScore.setBackground(new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("red_button13.png")), 24, 24, 24, 24))); gameScore.pad(32.f); Label scoreLabel = new Label("Score", new Label.LabelStyle( mFont, COLOR_FONT)); scoreLabel.setFontScale(1.2f); gameScore.add(scoreLabel).expand(); gameScore.row(); mScoreLabel = new Label("" + 0, new Label.LabelStyle(mFont, COLOR_FONT)); mScoreLabel.setFontScale(2.0f); gameScore.add(mScoreLabel).expand(); stage.addActor(gameScore); }
/** * * @param patches the frames to be drawn * @param frameDuration the delay between frames in seconds. */ public AnimatedNinePatchDrawable(Array<NinePatch> patches, float frameDuration) { this.patches = new Array<>(patches); t = 0.0f; this.frameDuration = frameDuration; index = 0; super.setPatch(patches.get(0)); }
public SvgNinePatchDrawable(NinePatch ninePatch, int leftWidth, int rightWidth, int topHeight, int bottomHeight) { super(ninePatch); if (topHeight >= 0) setTopHeight(topHeight); if (rightWidth >= 0) setRightWidth(rightWidth); if (bottomHeight >= 0) setBottomHeight(bottomHeight); if (leftWidth >= 0) setLeftWidth(leftWidth); }
public void setPatch(NinePatch patch) { super.setPatch(patch); setMinWidth(patch.getPadLeft() + patch.getPadRight()); setMinHeight(patch.getPadTop() + patch.getPadBottom()); setTopHeight(patch.getPadTop()); setRightWidth(patch.getPadRight()); setBottomHeight(patch.getPadBottom()); setLeftWidth(patch.getPadLeft()); }
public BorderedContainer(Skin skin, Actor actor) { NinePatch yellowPatch = skin.get("yellowPatch", NinePatch.class); border = new Image(yellowPatch); border.setPosition(-10, -10); this.actor = actor; addActor(border); addActor(actor); }
private NinePatchDrawable generateButton(Color color, Color down) { Pixmap pixmap = new Pixmap(9, 9, Pixmap.Format.RGBA8888); pixmap.setColor(down); pixmap.fill(); pixmap.setColor(color); pixmap.fillRectangle(0, 0, 9, 5); Texture texture = new Texture(pixmap); NinePatch ninePatch = new NinePatch(texture, 4, 4, 4, 4); return new NinePatchDrawable(ninePatch); }
@Override public void create() { super.create(); mapSize = 7; player1 = new Player("You"); player2 = new Player("Computer (Easy)"); turn = true; p1Score = new Button(player1.getName() + ": " + 0, 32, 540); p1Score.setWidth((2 * p1Score.getOffset()) + p1Score.getLayout().width + 16); p2Score = new Button(player2.getName() + ": " + 0, 1088, 540); p2Score.setWidth((2 * p2Score.getOffset()) + p2Score.getLayout().width + 16); table = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np.png")), 16, 16, 16, 16); for (int i = 0; i < mapSize; i++) { for (int k = 0; k < mapSize; k++) { maxitmap[i][k] = new Number((1280 - (72 * mapSize + 24)) / 2 + i * 72 + 16, (720 - (72 * mapSize + 24)) / 2 + k * 72 + 16); } } menu = new Button("Menu", 32, 45, Keys.M); reset = new Button("Reset", 32, 90, Keys.R); spointx = (new Random()).nextInt(mapSize); spointy = (new Random()).nextInt(mapSize); maxitmap[spointx][spointy].setState(3); }
public void styleSkin(Skin skin, TextureAtlas atlas) { BitmapFont font = new BitmapFont(Gdx.files.internal("data/lucida-console-21.fnt"), false); skin.add("default", font); skin.add("lt-blue", new Color(.6f, .8f, 1f, 1f)); skin.add("lt-green", new Color(.6f, .9f, .6f, 1f)); skin.add("dark-blue", new Color(.1f, .3f, 1f, 1f)); skin.add("button-text", Color.valueOf("DDFF35FF")); NinePatchDrawable btn1up = new NinePatchDrawable(atlas.createPatch("patchThick")); NinePatchDrawable btn1down = new NinePatchDrawable(atlas.createPatch("patchThickDown")); NinePatch window1patch = atlas.createPatch("window1"); skin.add("btn1up", btn1up); skin.add("btn1down", btn1down); skin.add("window1", window1patch); skin.add("white-pixel", atlas.findRegion("white-pixel"), TextureRegion.class); LabelStyle lbs = new LabelStyle(); lbs.font = font; lbs.fontColor = Color.WHITE; skin.add("default", lbs); TextButtonStyle tbs = new TextButtonStyle(btn1up, btn1down, btn1down, font); tbs.fontColor = skin.getColor("button-text"); tbs.pressedOffsetX = Math.round(1f * Gdx.graphics.getDensity()); tbs.pressedOffsetY = tbs.pressedOffsetX * -1f; skin.add("default", tbs); }
public void init(){ Drawable imageButton = new NinePatchDrawable(new NinePatch(Assets.getManager().get(Assets.VANNEBUTTON, Texture.class))); Button.ButtonStyle bts = new Button.ButtonStyle(imageButton,imageButton,imageButton); augmenter.setStyle(bts); augmenter.setSize(32, 64); augmenter.addListener(new VanneButton()); diminuer.setStyle(bts); diminuer.setSize(32, 64); diminuer.addListener(new VanneButton()); table.add(diminuer); table.add(augmenter); table.setPosition(x*64+32,y*64+32); //les 2 (+32) sont la pour être bien aligné avec le centre de la vanne }
public static NinePatchDrawable ninePatch(String region) { final NinePatch patch = skin.createPatch(region); if (patch == null) { throw new NullPointerException("9patch not found: " + region + ". Regions Available: " + skin.getRegions()); } return new NinePatchDrawable(patch); }
public SwampImage(NinePatch ninePatch) { super(ninePatch); originalImage = null; picture = null; setTouchable(false); }
public Button(BitmapFont font, NinePatch tex, String text, float x, float y, float width, float height){ super(font, text, x, y, width, height); this.text = text; this.font = font; this.nine_patch = tex; }
public SwitchButton(BitmapFont font, NinePatch patch, float x, float y, float width, float height, String key) { super(font, "No", x, y, width, height); this.key = key; this.nine_patch = patch; this.yes_string = "Yes"; this.no_string = "No"; }
public SwitchButton(BitmapFont font, NinePatch patch, float x, float y, float width, float height, String no, String yes, String key) { super(font, no, x, y, width, height); this.key = key; this.nine_patch = patch; this.yes_string = yes; this.no_string = no; }
public PlatformAssets(TextureAtlas atlas) { // TODO: Find the AtlasRegion holding the platform AtlasRegion region = atlas.findRegion(Constants.PLATFORM_SPRITE); // TODO: Turn that AtlasRegion into a NinePatch using the edge constant you defined int edge = Constants.PLATFORM_EDGE; platformNinePatch = new NinePatch(region, edge, edge, edge, edge); }
@Override public void create() { batch = new SpriteBatch(); viewport = new FitViewport(WORLD_SIZE, WORLD_SIZE); // TODO: Load the platform texture (Look for the file in android/assets) platformTexture = new Texture("platform.png"); // TODO: Initialize the NinePatch using the texture and the EDGE constant platformNinePatch = new NinePatch(platformTexture, EDGE, EDGE, EDGE, EDGE); }
public void setPatch (NinePatch patch) { this.patch = patch; setMinWidth(patch.getTotalWidth()); setMinHeight(patch.getTotalHeight()); setTopHeight(patch.getPadTop()); setRightWidth(patch.getPadRight()); setBottomHeight(patch.getPadBottom()); setLeftWidth(patch.getPadLeft()); }
public <T> T get (String name, Class<T> type) { if (name == null) throw new IllegalArgumentException("name cannot be null."); if (type == null) throw new IllegalArgumentException("type cannot be null."); if (type == Drawable.class) return (T)getDrawable(name); if (type == TextureRegion.class) return (T)getRegion(name); if (type == NinePatch.class) return (T)getPatch(name); if (type == Sprite.class) return (T)getSprite(name); ObjectMap<String, Object> typeResources = resources.get(type); if (typeResources == null) throw new GdxRuntimeException("No " + type.getName() + " registered with name: " + name); Object resource = typeResources.get(name); if (resource == null) throw new GdxRuntimeException("No " + type.getName() + " registered with name: " + name); return (T)resource; }