当前位置: 首页>>代码示例>>Java>>正文


Java NinePatchDrawable类代码示例

本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable的典型用法代码示例。如果您正苦于以下问题:Java NinePatchDrawable类的具体用法?Java NinePatchDrawable怎么用?Java NinePatchDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NinePatchDrawable类属于com.badlogic.gdx.scenes.scene2d.utils包,在下文中一共展示了NinePatchDrawable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findDrawable

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
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);
    }
 
开发者ID:varFamily,项目名称:cocos-ui-libgdx,代码行数:23,代码来源:CocoStudioUIEditor.java

示例2: shouldParseSingleButtonWithImages

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
@Test
@NeedGL
public void shouldParseSingleButtonWithImages() throws Exception {
    FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf");

    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("single-button/MainScene.json"), null, null, defaultFont, null);

    Group group = editor.createGroup();
    Actor actor = group.findActor("Button_1");

    assertThat(actor, not(nullValue()));
    assertThat(actor, instanceOf(ImageButton.class));
    ImageButton imageButton = (ImageButton) actor;
    assertThat(imageButton.getScaleX(), is(1.7958f));
    assertThat(imageButton.getScaleY(), is(1.8041f));
    ImageButton.ImageButtonStyle style = imageButton.getStyle();
    assertThat(style.imageDisabled, instanceOf(NinePatchDrawable.class));
    assertThat(style.up, instanceOf(NinePatchDrawable.class));
    assertThat(style.down, instanceOf(NinePatchDrawable.class));
}
 
开发者ID:varFamily,项目名称:cocos-ui-libgdx,代码行数:22,代码来源:CCButtonTest.java

示例3: addWindowStyles

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
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);
}
 
开发者ID:danirod,项目名称:rectball,代码行数:27,代码来源:RectballSkin.java

示例4: init

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
public static void init() {
   BUTTON_DEFAULT_ACTIVE.font = SharedAssetManager.getInstance().get(Assets.FONT_BYOM_32, BitmapFont.class);
   BUTTON_DEFAULT_ACTIVE.fontColor = Colors.COLOR_UI_ACTIVE.cpy();
   BUTTON_DEFAULT_ACTIVE.overFontColor = Colors.COLOR_UI_ACTIVE.add(-0.2f, -0.2f, -0.2f, 0f);
   Texture buttonTexture = SharedAssetManager.getInstance().get(Assets.BUTTON_DEFAULT, Texture.class);
   BUTTON_DEFAULT_ACTIVE.up = new NinePatchDrawable(
         GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_ACTIVE.fontColor));
   BUTTON_DEFAULT_ACTIVE.over = new NinePatchDrawable(
         GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_ACTIVE.overFontColor));

   BUTTON_DEFAULT_INACTIVE.font = SharedAssetManager.getInstance().get(Assets.FONT_BYOM_32, BitmapFont.class);
   BUTTON_DEFAULT_INACTIVE.fontColor = Colors.COLOR_UI_INACTIVE.cpy();
   BUTTON_DEFAULT_INACTIVE.overFontColor = Colors.COLOR_UI_INACTIVE.add(-0.2f, -0.2f, -0.2f, 0f);
   BUTTON_DEFAULT_INACTIVE.up = new NinePatchDrawable(
         GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_INACTIVE.fontColor));
   BUTTON_DEFAULT_INACTIVE.over = new NinePatchDrawable(
         GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_INACTIVE.overFontColor));
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:19,代码来源:Styles.java

示例5: addExit

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
private void addExit() {
	NinePatchDrawable draw = new NinePatchDrawable(Assets.hotkey.button);

	TextButtonStyle style = new ImageTextButtonStyle();
	style.up = draw;
	style.down = draw.tint(Color.DARK_GRAY);
	style.checked = draw;
	style.font = Assets.fonts.font;

	TextButton btn = new TextButton("Exit", style);
	btn.addListener(new ClickListener() {
		@Override
		public void clicked(InputEvent event, float x, float y) {
			super.clicked(event, x, y);
			Gdx.app.exit();
		}
	});
	table.add(btn);
	table.row();
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:21,代码来源:MainMenuScreen.java

示例6: add

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
public void add(String title, final AbstractScreen screen) {
	NinePatchDrawable draw = new NinePatchDrawable(Assets.hotkey.button);

	TextButtonStyle style = new ImageTextButtonStyle();
	style.up = draw;
	style.down = draw.tint(Color.DARK_GRAY);
	style.checked = draw;
	style.font = Assets.fonts.font;

	TextButton btn = new TextButton(title, style);
	btn.addListener(new ClickListener() {
		@Override
		public void clicked(InputEvent event, float x, float y) {
			super.clicked(event, x, y);
			GameManager.setScreen(screen);
		}
	});
	table.add(btn);
	table.row();

}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:22,代码来源:MainMenuScreen.java

示例7: AudioControl

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
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();
				}
			});
		}
	});
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:19,代码来源:AudioControl.java

示例8: initialize

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
private boolean initialize() {
  if (SharedAssetManager.isLoaded(Assets.TEX_PANEL_TRANSPARENT_9patch)
      && SharedAssetManager.isLoaded(Assets.FNT_MONO) && Styles.TXT_COMMANDLINE != null
      && Styles.TXT_COMMANDLINE.font != null) {
    setBackground(new NinePatchDrawable(GraphicsFactory.createNinePatch(Assets.TEX_PANEL_TRANSPARENT_9patch,
        Sizes.panelTransparentRadius())));
    textField = new TextField("", Styles.TXT_COMMANDLINE);
    textField.setWidth(getWidth());
    LabelStyle consoleStyle = new LabelStyle();
    consoleStyle.font = SharedAssetManager.get(Assets.FNT_MONO, BitmapFont.class);
    consoleStyle.fontColor = Color.GRAY;
    add(new Label("$ ", consoleStyle));
    add(textField).width(getWidth());
    setY(Sizes.worldHeight() - textField.getHeight());
    setHeight(textField.getHeight());
    return true;
  } else {
    return false;
  }
}
 
开发者ID:bitbrain,项目名称:craft,代码行数:21,代码来源:CommandLineInterface.java

示例9: addTile

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
/**
 * 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)
}
 
开发者ID:Vhati,项目名称:OverdriveGDX,代码行数:19,代码来源:ShipFloorLinesActor.java

示例10: addTile

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
/**
 * 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)
}
 
开发者ID:Vhati,项目名称:OverdriveGDX,代码行数:19,代码来源:ShipFloorTilesActor.java

示例11: textWindowDemo

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
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 );
}
 
开发者ID:Vhati,项目名称:OverdriveGDX,代码行数:27,代码来源:TestScreen.java

示例12: newDrawable

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
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());
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:26,代码来源:Skin.java

示例13: layout

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
public final void layout()
{
  Object localObject = null;
  if (needsLayout())
  {
    float f1 = l.a(12.0F) / 2.0F;
    this.f.clear();
    a(null, null);
    Iterator localIterator = this.d.iterator();
    while (localIterator.hasNext())
    {
      Integer localInteger = (Integer)localIterator.next();
      Button localButton = new Button(com.nianticproject.ingress.common.b.c.a(this.b, localInteger.intValue()));
      com.nianticproject.ingress.common.ui.widget.d locald = new com.nianticproject.ingress.common.ui.widget.d(new NinePatchDrawable(this.b.getPatch("avatar-color-picker-button-up")), new NinePatchDrawable(this.b.getPatch("avatar-color-picker-button-down")), new NinePatchDrawable(this.b.getPatch("avatar-color-picker-button-checked")));
      locald.addListener(new b(this, locald, localInteger));
      if (localObject == null)
        localObject = locald;
      this.f.stack(new Actor[] { localButton, locald }).b(this.h).c(this.h).i(f1).k(f1);
      if ((this.e.a != null) && (ag.a(this.e.a, localInteger)))
        a(locald, Integer.valueOf(localInteger.intValue()));
    }
    if ((this.e.b == null) && (localObject != null))
      a(localObject, (Integer)this.d.get(0));
    super.layout();
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:27,代码来源:a.java

示例14: a

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
private static Actor a(com.nianticproject.ingress.shared.playerprofile.a parama, Skin paramSkin, WidgetCarousel paramWidgetCarousel, e parame, a parama1)
{
  Table localTable1 = new Table();
  localTable1.setBackground(new NinePatchDrawable(paramSkin.getPatch("avatar-color-picker-button-up")));
  Label.LabelStyle localLabelStyle = (Label.LabelStyle)paramSkin.get("profiles-avatar-selection-layer-name", Label.LabelStyle.class);
  localTable1.add(new Label(parama.name() + ":", localLabelStyle)).o();
  paramWidgetCarousel.a(parame);
  localTable1.row();
  localTable1.add(paramWidgetCarousel).h(l.a(8.0F)).j(l.a(8.0F)).o().g();
  localTable1.row();
  localTable1.add(new Image(com.nianticproject.ingress.common.b.c.a(paramSkin, 46783))).o().g().c(l.a(1.0F));
  localTable1.row();
  localTable1.add(parama1).g(parama1.a()).o().g();
  Table localTable2 = new Table();
  Table localTable3 = new Table();
  localTable3.setBackground(paramSkin.getTiledDrawable("tile-diag"));
  localTable2.stack(new Actor[] { localTable3, localTable1 }).o().g();
  return localTable2;
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:20,代码来源:o.java

示例15: a

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; //导入依赖的package包/类
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);
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:20,代码来源:bm.java


注:本文中的com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。