本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.utils.Drawable類的典型用法代碼示例。如果您正苦於以下問題:Java Drawable類的具體用法?Java Drawable怎麽用?Java Drawable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Drawable類屬於com.badlogic.gdx.scenes.scene2d.utils包,在下文中一共展示了Drawable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: _init
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
public void _init(Drawable[] textures, int depth, Vector2[] bias) {
if (bias != null && bias.length != textures.length)
throw new IllegalArgumentException();
group = new Group();
images = new Image[textures.length];
for (int i=0; i<textures.length; i++) {
Drawable texture = textures[i];
Image image = new Image(texture);
images[i] = image;
image.setBounds(0, 0, texture.getMinWidth(), texture.getMinHeight());
if (bias != null)
image.setPosition(bias[i].x, bias[i].y, Align.center);
else
image.setPosition(0, 0, Align.center);
group.addActor(image);
}
mDepth = depth;
biases = bias;
}
示例2: drawStageBackground
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
@Override
protected void drawStageBackground(Batch batch, float parentAlpha, float x,
float y, float width, float height) {
Drawable background = getStyle().stageBackground;
float drawableWidth = background.getMinWidth();
float drawableHeight = background.getMinHeight();
if (drawableWidth < width || drawableHeight < height) {
Vector2 tempVector = MathUtil.getVector2();
Stage stage = getStage();
x = stage.getWidth()/2 - drawableWidth/2;
y = stage.getHeight()/2 - drawableHeight/2;
//stageToLocalCoordinates(tempVector.set(x, y));
//x = tempVector.x;
//y = tempVector.y;
MathUtil.freeVector2(tempVector);
width = background.getMinWidth();
height = background.getMinHeight();
}
super.drawStageBackground(batch, parentAlpha, x, y, width, height);
}
示例3: fillRoundedRect
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
@Override
public void fillRoundedRect(float x, float y, float w, float h, int cornerRadius) {
Drawable drawable = getRoundedRectDrawable(cornerRadius);
Color originalColor = null;
ensureSpriteBatchOpen();
if (brushType == BrushType.COLOR) {
originalColor = spriteBatch.getColor();
Color color = getAlphaMultiplied(colorBrush);
spriteBatch.setColor(color);
freeColor(color);
}
drawable.draw(spriteBatch, x, viewportSize.y - y - h, w, h);
if (originalColor != null) {
spriteBatch.setColor(originalColor);
}
}
示例4: getRoundedRectDrawable
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
private Drawable getRoundedRectDrawable(int radius) {
switch (radius) {
case 1:
case 2:
return getDefaultToolkit().getSkin().getDrawable("rounded_rect_2");
case 3:
return getDefaultToolkit().getSkin().getDrawable("rounded_rect_3");
case 4:
return getDefaultToolkit().getSkin().getDrawable("rounded_rect_4");
case 5:
return getDefaultToolkit().getSkin().getDrawable("rounded_rect_5");
case 6:
return getDefaultToolkit().getSkin().getDrawable("rounded_rect_6");
default:
return getDefaultToolkit().getSkin().getDrawable("rounded_rect_2");
}
}
示例5: stylePropertyChanged
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
@Override
public void stylePropertyChanged(StyleProperty styleProperty,
Actor styleActor) {
if (styleProperty.type == Drawable.class) {
dialogFactory.showDialogDrawables(styleProperty);
} else if (styleProperty.type == Color.class) {
dialogFactory.showDialogColors(styleProperty);
} else if (styleProperty.type == BitmapFont.class) {
dialogFactory.showDialogFonts(styleProperty);
} else if (styleProperty.type == Float.TYPE) {
main.getUndoableManager().addUndoable(new UndoableManager.DoubleUndoable(main, styleProperty, ((Spinner) styleActor).getValue()), false);
} else if (styleProperty.type == ScrollPaneStyle.class) {
main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true);
} else if (styleProperty.type == LabelStyle.class) {
main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true);
} else if (styleProperty.type == ListStyle.class) {
main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true);
}
}
示例6: setValue
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
public void setValue(int value) {
if (value < 0 || value > 10) {
throw new RuntimeException("value must between 0-10! it was:" + Integer.toString(value));
}
Skin skin = VisUI.getSkin();
Drawable star1 = value >= 2 ? skin.getDrawable("star") : value >= 1 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
Drawable star2 = value >= 4 ? skin.getDrawable("star") : value >= 3 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
Drawable star3 = value >= 6 ? skin.getDrawable("star") : value >= 5 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
Drawable star4 = value >= 8 ? skin.getDrawable("star") : value >= 7 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
Drawable star5 = value == 10 ? skin.getDrawable("star") : value >= 9 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
setImage(image1, star1);
setImage(image2, star2);
setImage(image3, star3);
setImage(image4, star4);
setImage(image5, star5);
this.invalidateHierarchy();
}
示例7: findDrawable
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的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);
}
示例8: getFontIcon
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
private Drawable getFontIcon(FileChooser.FileItem item) {
FileHandle fileHandle = item.getFile();
BitmapFont bitmapFont;
try {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = CB.getScaledInt(50);
parameter.characters = SkinFont.DEFAULT_CHARACTER;
parameter.genMipMaps = true;
parameter.minFilter = Texture.TextureFilter.MipMapNearestNearest;
bitmapFont = generator.generateFont(parameter);
} catch (Exception e) {
return getImageIcon(item);
}
Drawable drawable = new BitmapFontDrawable(bitmapFont, item.getFile().nameWithoutExtension());
return drawable;
}
示例9: ReloadCacheActivity
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
public ReloadCacheActivity() {
super("CheckStateActivity");
bCancel = new CharSequenceButton(Translation.get("cancel"));
gsLogo = new Image(CB.getSkin().getIcon.GC_Live);
lblTitle = new VisLabel(Translation.get("ReloadCacheAPI"));
Label.LabelStyle style = new Label.LabelStyle(lblTitle.getStyle());
style.fontColor.set(Color.WHITE);
lblTitle.setStyle(style);
Drawable animationDrawable = VisUI.getSkin().getDrawable("download-animation");
workAnimation = new Image(animationDrawable);
progressBar = new VisProgressBar(0, 100, 1, false, "default");
createOkCancelBtn();
setWorkAnimationVisible(false);
this.setStageBackground(new ColorDrawable(VisUI.getSkin().getColor("dialog_background")));
// this.setDebug(true, true);
}
示例10: parse
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {
TImage image;
Drawable tr = editor.findDrawable(widget, widget.getFileData());
if (tr == null) {
return new TImage();
}
image = new TImage(tr);
String buttonType = widget.getButtonType();
if (buttonType != null) {
switch (buttonType) {
case "ScaleButton":
image.isButton();
break;
case "ColorButton":
image.isColorButton();
break;
default:
image.isNoButton();
break;
}
}
return image;
}
示例11: parseButton
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
private static void parseButton(Button button, XmlReader.Element element){
String upPath = element.get("up");
String downPath = element.get("down");
String checkPath = element.get("check");
Drawable up = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal(upPath))));
Drawable down = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal(downPath))));
Drawable checked = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal(checkPath))));
Button.ButtonStyle buttonStyle = new Button.ButtonStyle(up,down,checked);
button.setStyle(buttonStyle);
}
示例12: parseButton
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
public static void parseButton(VisImageButton button, XmlReader.Element element){
String upPath = element.get("up");
String downPath = element.get("down");
String checkPath = element.get("check");
Drawable up = new TextureRegionDrawable(new TextureRegion(new Texture(Config.getImageFilePath(upPath))));
Drawable down = new TextureRegionDrawable(new TextureRegion(new Texture(Config.getImageFilePath(downPath))));
Drawable checked = new TextureRegionDrawable(new TextureRegion(new Texture(Config.getImageFilePath(checkPath))));
VisImageButton.VisImageButtonStyle buttonStyle = new VisImageButton.VisImageButtonStyle(
up,down,checked,up,down,checked
);
button.setStyle(buttonStyle);
attr2Button(button, new String[]{upPath, downPath, checkPath});
}
示例13: Initialize
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
@Override
public void Initialize(Entity entity) {
super.Initialize(entity);
animationDrawable.setAnimation(animationStay);
existTime = 0;
entity.AddComponent(mRenderer = new ImageGroupRenderer(new Drawable[] { animationDrawable, playerAnimation }, 0, null));
mReimuWing1 = new ReimuWing(new Vector2(transform.position.x, transform.position.y + 20), 4f, mType);
mReimuWing2 = new ReimuWing(new Vector2(transform.position.x, transform.position.y), -4f, mType);
}
示例14: LogMenu
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
public LogMenu() {
label = new Label("", new LabelStyle(Fonts.smallHUD, Color.BLACK));
label.setWrap(true);
Drawable background = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/LogBackground.png"));
scrollPane = new ScrollPane(label, new ScrollPaneStyle(background, null, null, null, null));
scrollPane.setScrollingDisabled(true, false);
back = MenuTools.getBackButton(this);
stage.addActor(scrollPane);
stage.addActor(back);
refresh();
}
示例15: BouncingImage
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; //導入依賴的package包/類
/** @param drawable May be null. */
public BouncingImage (Drawable drawable, Scaling scaling, int align) {
setDrawable(drawable);
this.scaling = scaling;
this.align = align;
setSize(getPrefWidth(), getPrefHeight());
addBounce();
}