本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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));
}
示例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();
}
示例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();
}
示例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();
}
});
}
});
}
示例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;
}
}
示例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)
}
示例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)
}
示例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 );
}
示例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());
}
示例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();
}
}
示例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;
}
示例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);
}