本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Image.<init>()
方法的一些代码示例,展示了Image.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Image.<init>()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Image
类名称:Image
方法名:<init>
[英]Creates an image with no drawable, stretched, and aligned center.
[中]创建没有可绘制、拉伸和对齐中心的图像。
代码示例来源:origin: libgdx/libgdx
public ImageButton (ImageButtonStyle style) {
super(style);
image = new Image();
image.setScaling(Scaling.fit);
add(image);
setStyle(style);
setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: libgdx/libgdx
public ImageButton (ImageButtonStyle style) {
super(style);
image = new Image();
image.setScaling(Scaling.fit);
add(image);
setStyle(style);
setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: libgdx/libgdx
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
texture = new Texture("data/group-debug.png");
Image image = new Image(texture);
image.setScaling(Scaling.fit);
image.setBounds(100, 100, 400, 200);
stage.addActor(image);
Image image2 = new Image(texture);
image2.setScaling(Scaling.fit);
image.setBounds(100, 100, 400, 200);
image2.setOrigin(200, 100);
image2.setScale(0.5f);
stage.addActor(image2);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
stage = new Stage();
for (int i = 0; i < 100; i++) {
Image img = new Image(new TextureRegion(texture));
img.setX((float)Math.random() * 480);
img.setY((float)Math.random() * 320);
img.getColor().a = (float)Math.random() * 0.5f + 0.5f;
stage.addActor(img);
}
stage.getRoot().addAction(forever(sequence(fadeOut(3), fadeIn(3))));
}
代码示例来源:origin: libgdx/libgdx
public CheckBox (String text, CheckBoxStyle style) {
super(text, style);
clearChildren();
Label label = getLabel();
imageCell = add(image = new Image(style.checkboxOff, Scaling.none));
add(label);
label.setAlignment(Align.left);
setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: libgdx/libgdx
public CheckBox (String text, CheckBoxStyle style) {
super(text, style);
clearChildren();
Label label = getLabel();
imageCell = add(image = new Image(style.checkboxOff, Scaling.none));
add(label);
label.setAlignment(Align.left);
setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
batch = new SpriteBatch();
font = new BitmapFont();
stage = new Stage(new ScalingViewport(Scaling.fit, 24, 12));
regions = new TextureRegion[8 * 8];
sprites = new Sprite[24 * 12];
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
regions[x + y * 8] = new TextureRegion(texture, x * 32, y * 32, 32, 32);
}
}
Random rand = new Random();
for (int y = 0, i = 0; y < 12; y++) {
for (int x = 0; x < 24; x++) {
Image img = new Image(regions[rand.nextInt(8 * 8)]);
img.setBounds(x, y, 1, 1);
stage.addActor(img);
sprites[i] = new Sprite(regions[rand.nextInt(8 * 8)]);
sprites[i].setPosition(x, y);
sprites[i].setSize(1, 1);
i++;
}
}
}
代码示例来源:origin: libgdx/libgdx
private void fillGroup (Group group, Texture texture) {
float advance = 32 + SPACING;
for (int y = 0; y < NUM_SPRITES * advance; y += advance)
for (int x = 0; x < NUM_SPRITES * advance; x += advance) {
Image img = new Image(new TextureRegion(texture));
img.setAlign(Align.center);
img.setScaling(Scaling.none);
img.setBounds(x, y, 32, 32);
img.setOrigin(16, 16);
group.addActor(img);
sprites.add(img);
}
}
代码示例来源:origin: libgdx/libgdx
ScrollPane pane2 = new ScrollPane(new Image(new Texture("data/group-debug.png")), skin);
pane2.setScrollingDisabled(false, true);
mytable.add(new Image(new Texture("data/group-debug.png")));
mytable.row();
mytable.add(new Image(new Texture("data/group-debug.png")));
mytable.row();
mytable.add(pane2).size(100);
mytable.row();
mytable.add(new Image(new Texture("data/group-debug.png")));
mytable.row();
mytable.add(new Image(new Texture("data/group-debug.png")));
代码示例来源:origin: libgdx/libgdx
for (int i = 1; i <= 15; i++) {
horiz.addActor(new Label(i + ",", style));
if (i == 7) horiz.addActor(new Container(new Image(texture)).size(10));
horiz.addActor(new Container(new Image(texture)).fill().prefSize(30));
horiz.debug();
horiz.setPosition(10, 10);
for (int i = 1; i <= 15; i++) {
horizWrap.addActor(new Label(i + ",", style));
if (i == 7) horizWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
horizWrap.addActor(new Container(new Image(texture)).prefSize(30));
horizWrap.debug();
horizWrap.setBounds(10, 85, 150, 40);
for (int i = 1; i <= 8; i++) {
vert.addActor(new Label(i + ",", style));
if (i == 4) vert.addActor(new Container(new Image(texture)).size(10));
vert.addActor(new Container(new Image(texture)).size(30));
vert.debug();
vert.setPosition(515, 10);
for (int i = 1; i <= 8; i++) {
vertWrap.addActor(new Label(i + ",", style));
if (i == 4) vertWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
vertWrap.addActor(new Container(new Image(texture)).prefSize(30));
代码示例来源:origin: libgdx/libgdx
skin.add("badlogic", new Texture("data/badlogic.jpg"));
Image sourceImage = new Image(skin, "badlogic");
sourceImage.setBounds(50, 125, 100, 100);
stage.addActor(sourceImage);
Image validTargetImage = new Image(skin, "badlogic");
validTargetImage.setBounds(200, 50, 100, 100);
stage.addActor(validTargetImage);
Image invalidTargetImage = new Image(skin, "badlogic");
invalidTargetImage.setBounds(200, 200, 100, 100);
stage.addActor(invalidTargetImage);
代码示例来源:origin: libgdx/libgdx
public ImageTextButton (String text, ImageTextButtonStyle style) {
super(style);
this.style = style;
defaults().space(3);
image = new Image();
image.setScaling(Scaling.fit);
label = new Label(text, new LabelStyle(style.font, style.fontColor));
label.setAlignment(Align.center);
add(image);
add(label);
setStyle(style);
setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: libgdx/libgdx
public ImageTextButton (String text, ImageTextButtonStyle style) {
super(style);
this.style = style;
defaults().space(3);
image = new Image();
image.setScaling(Scaling.fit);
label = new Label(text, new LabelStyle(style.font, style.fontColor));
label.setAlignment(Align.center);
add(image);
add(label);
setStyle(style);
setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
stage = new Stage();
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
img = new Image(new TextureRegion(texture));
img.setSize(100, 100);
img.setOrigin(50, 50);
img.setPosition(100, 100);
img2 = new Image(new TextureRegion(texture));
img2.setSize(100, 100);
img2.setOrigin(50, 50);
img2.setPosition(100, 100);
img3 = new Image(new TextureRegion(texture));
img3.setSize(100, 100);
img3.setOrigin(50, 50);
img3.setPosition(100, 100);
stage.addActor(img);
stage.addActor(img2);
stage.addActor(img3);
img.addAction(sequence());
img2.addAction(parallel(sequence(), moveBy(100, 0, 1)));
img3.addAction(sequence(parallel(moveBy(100, 200, 2)), Actions.run(this)));
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
stage = new Stage();
Action complexAction = forever(sequence(parallel(rotateBy(180, 2), scaleTo(1.4f, 1.4f, 2), alpha(0.7f, 2)),
parallel(rotateBy(180, 2), scaleTo(1.0f, 1.0f, 2), alpha(1.0f, 2))));
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
final Image img1 = new Image(new TextureRegion(texture));
img1.setSize(100, 100);
img1.setOrigin(50, 50);
img1.setPosition(50, 50);
final Image img2 = new Image(new TextureRegion(texture));
img2.setSize(50, 50);
img2.setOrigin(50, 50);
img2.setPosition(150, 150);
stage.addActor(img1);
stage.addActor(img2);
img1.addAction(complexAction);
// img2.action(complexAction.copy());
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
stage = new Stage();
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
final Image img = new Image(new TextureRegion(texture));
img.setSize(100, 100);
img.setOrigin(50, 50);
img.setPosition(100, 100);
// img.addAction(forever(sequence(delay(1.0f), new Action() {
// public boolean act (float delta) {
// System.out.println(1);
// img.clearActions();
// return true;
// }
// })));
img.addAction(Actions.moveBy(100, 0, 2));
img.addAction(Actions.after(Actions.scaleTo(2, 2, 2)));
stage.addActor(img);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
image2 = new TextureRegion(new Texture(Gdx.files.internal("data/badlogic.jpg")));
ui = new Stage();
Gdx.input.setInputProcessor(ui);
root = new Table();
root.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
ui.addActor(root);
root.debug();
Image image = new Image(image2);
image.setScaling(Scaling.fill);
root.add(image).width(image2.getRegionWidth()).height(image2.getRegionHeight());
}
代码示例来源:origin: libgdx/libgdx
ui = new Stage(new ScreenViewport());
Image blend = new Image(new TextureRegion(uiTexture, 0, 0, 64, 32));
blend.setAlign(Align.center);
blend.setScaling(Scaling.none);
blend.setY(ui.getHeight() - 64);
Image rotate = new Image(new TextureRegion(uiTexture, 64, 0, 64, 32));
rotate.setAlign(Align.center);
rotate.setScaling(Scaling.none);
rotate.setPosition(64, blend.getY());
Image scale = new Image(new TextureRegion(uiTexture, 64, 32, 64, 32));
scale.setAlign(Align.center);
scale.setScaling(Scaling.none);
代码示例来源:origin: libgdx/libgdx
table.add(new Image(skin.newDrawable("white", Color.RED))).size(64);
代码示例来源:origin: libgdx/libgdx
Button imgButton = new Button(new Image(image), skin);
Button imgToggleButton = new Button(new Image(image), skin, "toggle");
"OSX5", "Android6", "Windows6", "Linux6", "OSX6", "Android7", "Windows7", "Linux7", "OSX7");
selectBox.setSelected("Linux6");
Image imageActor = new Image(image2);
ScrollPane scrollPane = new ScrollPane(imageActor);
List list = new List(skin);
内容来源于网络,如有侵权,请联系作者删除!