本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.addActor()
方法的一些代码示例,展示了Stage.addActor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.addActor()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:addActor
[英]Adds an actor to the root of the stage.
[中]将演员添加到舞台的根部。
代码示例来源:origin: libgdx/libgdx
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
touchpad = new Touchpad(20, skin);
touchpad.setBounds(15, 15, 100, 100);
stage.addActor(touchpad);
}
代码示例来源: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
public void run () {
if (showTooltip == null || showTooltip.targetActor == null) return;
Stage stage = showTooltip.targetActor.getStage();
if (stage == null) return;
stage.addActor(showTooltip.container);
showTooltip.container.toFront();
shown.add(showTooltip);
showTooltip.container.clearActions();
showAction(showTooltip);
if (!showTooltip.instant) {
time = subsequentTime;
resetTask.cancel();
}
}
};
代码示例来源:origin: libgdx/libgdx
public void run () {
if (showTooltip == null || showTooltip.targetActor == null) return;
Stage stage = showTooltip.targetActor.getStage();
if (stage == null) return;
stage.addActor(showTooltip.container);
showTooltip.container.toFront();
shown.add(showTooltip);
showTooltip.container.clearActions();
showAction(showTooltip);
if (!showTooltip.instant) {
time = subsequentTime;
resetTask.cancel();
}
}
};
代码示例来源: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
@Override
public void create () {
super.create();
modelCache = new ModelCache();
cacheCheckBox = new CheckBox("Cache", skin);
cacheCheckBox.setChecked(false);
cacheCheckBox.setPosition(hudWidth - cacheCheckBox.getWidth(), moveCheckBox.getTop());
hud.addActor(cacheCheckBox);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
// create a stage and a camera controller so we can pan the view.
stage = new Stage();;
camController = new OrthoCamController((OrthographicCamera)stage.getCamera()); // we know it's an ortho cam at this point!
Gdx.input.setInputProcessor(camController);
// load a dummy texture
texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
// populate the stage with some actors and groups.
for (int i = 0; i < 5000; i++) {
Actor img = new CullableActor("img" + i, texture, (OrthographicCamera)stage.getCamera());
img.setX((float)Math.random() * 480 * 10);
img.setY((float)Math.random() * 320 * 10);
stage.addActor(img);
}
// we also want to output the number of visible actors, so we need a SpriteBatch and a BitmapFont
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
TextArea textArea = new TextArea(
"Text Area\nEssentially, a text field\nwith\nmultiple\nlines.\n"
+ "It can even handle very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong lines.",
skin);
textArea.setX(10);
textArea.setY(10);
textArea.setWidth(200);
textArea.setHeight(200);
TextField textField = new TextField("Text field", skin);
textField.setX(10);
textField.setY(220);
textField.setWidth(200);
textField.setHeight(30);
stage.addActor(textArea);
stage.addActor(textField);
}
代码示例来源:origin: libgdx/libgdx
public void create () {
Batch batch = new CpuSpriteBatch();
// batch = new SpriteBatch();
stage = new Stage(new ExtendViewport(500, 500), batch);
Gdx.input.setInputProcessor(stage);
texture = new Texture("data/bobargb8888-32x32.png");
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(texture));
for (int i = 0; i < NUM_GROUPS; i++) {
Group group = createActorGroup(drawable);
stage.addActor(group);
}
}
代码示例来源:origin: libgdx/libgdx
private void setupUI () {
Skin skin = assets.get(DEFAULT_SKIN);
Table table = new Table();
table.setFillParent(true);
table.top().left().add(new Label("FPS ", skin)).left();
table.add(fpsLabel = new Label("", skin)).left().expandX().row();
ui.addActor(table);
}
代码示例来源:origin: libgdx/libgdx
/** {@link #pack() Packs} the dialog (but doesn't set the position), adds it to the stage, sets it as the keyboard and scroll
* focus, clears any actions on the dialog, and adds the specified action to it. The previous keyboard and scroll focus are
* remembered so they can be restored when the dialog is hidden.
* @param action May be null. */
public Dialog show (Stage stage, Action action) {
clearActions();
removeCaptureListener(ignoreTouchDown);
previousKeyboardFocus = null;
Actor actor = stage.getKeyboardFocus();
if (actor != null && !actor.isDescendantOf(this)) previousKeyboardFocus = actor;
previousScrollFocus = null;
actor = stage.getScrollFocus();
if (actor != null && !actor.isDescendantOf(this)) previousScrollFocus = actor;
pack();
stage.addActor(this);
stage.cancelTouchFocus();
stage.setKeyboardFocus(this);
stage.setScrollFocus(this);
if (action != null) addAction(action);
return this;
}
代码示例来源:origin: libgdx/libgdx
/** {@link #pack() Packs} the dialog (but doesn't set the position), adds it to the stage, sets it as the keyboard and scroll
* focus, clears any actions on the dialog, and adds the specified action to it. The previous keyboard and scroll focus are
* remembered so they can be restored when the dialog is hidden.
* @param action May be null. */
public Dialog show (Stage stage, Action action) {
clearActions();
removeCaptureListener(ignoreTouchDown);
previousKeyboardFocus = null;
Actor actor = stage.getKeyboardFocus();
if (actor != null && !actor.isDescendantOf(this)) previousKeyboardFocus = actor;
previousScrollFocus = null;
actor = stage.getScrollFocus();
if (actor != null && !actor.isDescendantOf(this)) previousScrollFocus = actor;
pack();
stage.addActor(this);
stage.cancelTouchFocus();
stage.setKeyboardFocus(this);
stage.setScrollFocus(this);
if (action != null) addAction(action);
return this;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
for (int i = 0; i < 1; i++) {
TextButton t = new TextButton("Button" + i, skin);
t.setX(MathUtils.random(0, Gdx.graphics.getWidth()));
t.setY(MathUtils.random(0, Gdx.graphics.getHeight()));
t.setWidth(MathUtils.random(50, 200));
t.setHeight(MathUtils.random(0, 100));
stage.addActor(t);
}
}
代码示例来源: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
protected CollapsableWindow addListWindow (String title, List list, float x, float y) {
CollapsableWindow window = new CollapsableWindow(title, skin);
window.row();
ScrollPane pane = new ScrollPane(list, skin);
pane.setFadeScrollBars(false);
window.add(pane);
window.pack();
window.pack();
if (window.getHeight() > hudHeight) {
window.setHeight(hudHeight);
}
window.setX(x < 0 ? hudWidth - (window.getWidth() - (x + 1)) : x);
window.setY(y < 0 ? hudHeight - (window.getHeight() - (y + 1)) : y);
window.layout();
window.collapse();
hud.addActor(window);
pane.setScrollX(0);
pane.setScrollY(0);
return window;
}
代码示例来源:origin: libgdx/libgdx
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
root = new Table();
root.setFillParent(true);
stage.addActor(root);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
Table labels = new Table();
root.add(new ScrollPane(labels, skin)).expand().fill();
root.row();
root.add(drawnLabel = new Label("", skin));
for (int i = 0; i < count; i++) {
labels.add(new Label("Label: " + i, skin) {
public void draw (Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
drawn++;
}
});
labels.row();
}
}
代码示例来源: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
@Override
public void create () {
batch = new SpriteBatch();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Table table = new Table();
stage.addActor(table);
table.setPosition(200, 65);
Label label1 = new Label("This text is scaled 2x.", skin);
label1.setFontScale(2);
Label label2 = new Label(
"This text is scaled. This text is scaled. This text is scaled. This text is scaled. This text is scaled. ", skin);
label2.setWrap(true);
label2.setFontScale(0.75f, 0.75f);
table.debug();
table.add(label1);
table.row();
table.add(label2).fill();
table.pack();
}
代码示例来源:origin: libgdx/libgdx
private void setupUI () {
ui = new Stage(new ExtendViewport(640, 480));
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
skipCleanup = new CheckBox("Skip blend function clean-up", skin);
skipCleanup.addListener(listener);
logLabel = new Label("", skin.get(LabelStyle.class));
clearEmitters = new TextButton("Clear screen", skin);
clearEmitters.addListener(listener);
scaleEffects = new TextButton("Scale existing effects", skin);
scaleEffects.addListener(listener);
Table table = new Table();
table.setTransform(false);
table.setFillParent(true);
table.defaults().padTop(5).left();
table.top().left().padLeft(5);
table.add(skipCleanup).colspan(2).row();
table.add(clearEmitters).spaceRight(10);
table.add(scaleEffects).row();
table.add(logLabel).colspan(2);
ui.addActor(table);
}
内容来源于网络,如有侵权,请联系作者删除!