本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.<init>()
方法的一些代码示例,展示了Stage.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.<init>()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:<init>
[英]Creates a stage with a ScalingViewport set to Scaling#stretch. The stage will use its own Batchwhich will be disposed when the stage is disposed.
[中]创建缩放视口设置为缩放#拉伸的舞台。该阶段将使用自己的批次,在处理该阶段时进行处理。
代码示例来源: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
@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 () {
// 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 () {
super.create();
emitters = new Array<ParticleController>();
assets.load(DEFAULT_PARTICLE, Texture.class);
assets.load(DEFAULT_SKIN, Skin.class);
loading = true;
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0f, 0f, 0.1f, 1f));
environment.add(new DirectionalLight().set(1f, 1f, 1f, 0, -0.5f, -1 ));
billboardParticleBatch = new BillboardParticleBatch();
billboardParticleBatch.setCamera(cam);
ui = new Stage();
builder = new StringBuilder();
}
代码示例来源: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
@Override
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
//Create a string that perfectly fills the float array used in the textarea float array
FloatArray dummyArray = new FloatArray();
String limit = "";
// Minus one, because TextField adds a magic char
for (int i = 0; i < dummyArray.items.length-1; i++) {
limit += "a";
}
TextArea textArea = new TextArea(
limit,
skin);
textArea.setX(10);
textArea.setY(10);
textArea.setWidth(200);
textArea.setHeight(200);
stage.addActor(textArea);
}
代码示例来源: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 () {
batch = new SpriteBatch();
texture = new Texture("data/badlogic.jpg");
region = new TextureRegion(texture);
stage = new Stage(new ScreenViewport(), batch);
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
skin.add("default", font = new BitmapFont(Gdx.files.internal("data/arial-32.fnt"), false));
populateTable();
Gdx.graphics.setContinuousRendering(false);
Gdx.graphics.requestRendering();
}
代码示例来源: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();
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 () {
if (app == null) {
app = Gdx.app;
tests[testIndex].create();
}
cameraController = new CameraInputController(tests[testIndex].camera);
cameraController.activateKey = Keys.CONTROL_LEFT;
cameraController.autoUpdate = false;
cameraController.forwardTarget = false;
cameraController.translateTarget = false;
Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
hud = new Stage();
hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE)));
fpsLabel.setPosition(0, 0);
hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE)));
titleLabel.setY(hud.getHeight() - titleLabel.getHeight());
hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE)));
instructLabel.setY(titleLabel.getY() - instructLabel.getHeight());
instructLabel.setAlignment(Align.top | Align.left);
instructLabel.setText(tests[testIndex].instructions);
}
代码示例来源: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 () {
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 () {
// setup a tiny ui with a console and a clear button.
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage();
ui = new Table();
ui.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
console = new List(skin);
scrollPane = new ScrollPane(console);
scrollPane.setScrollbarsOnTop(true);
TextButton clear = new TextButton("Clear", skin);
ui.add(scrollPane).expand(true, true).fill();
ui.row();
ui.add(clear).expand(true, false).fill();
stage.addActor(ui);
clear.addListener(new ClickListener() {
@Override
public void clicked (InputEvent event, float x, float y) {
clear();
}
});
Gdx.input.setInputProcessor(stage);
}
代码示例来源:origin: libgdx/libgdx
public void setupUI () {
ui = new Stage();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
TextButton reload = new TextButton("Reload Shaders", skin.get(TextButtonStyle.class));
camera = new SelectBox(skin.get(SelectBoxStyle.class));
camera.setItems("Camera", "Light");
fps = new Label("fps: ", skin.get(LabelStyle.class));
Table table = new Table();
table.setFillParent(true);
table.top().padTop(15);
table.add(reload).spaceRight(5);
table.add(camera).spaceRight(5);
table.add(fps);
ui.addActor(table);
reload.addListener(new ClickListener() {
public void clicked (InputEvent event, float x, float y) {
ShaderProgram prog = new ShaderProgram(Gdx.files.internal("data/shaders/projtex-vert.glsl").readString(), Gdx.files
.internal("data/shaders/projtex-frag.glsl").readString());
if (prog.isCompiled() == false) {
Gdx.app.log("GLSL ERROR", "Couldn't reload shaders:\n" + prog.getLog());
} else {
projTexShader.dispose();
projTexShader = prog;
}
}
});
}
代码示例来源: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
private void createUI () {
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
ui = new Stage();
String[] filters = new String[TextureFilter.values().length];
int idx = 0;
for (TextureFilter filter : TextureFilter.values()) {
filters[idx++] = filter.toString();
}
hwMipMap = new CheckBox("Hardware Mips", skin);
minFilter = new SelectBox(skin);
minFilter.setItems(filters);
magFilter = new SelectBox(skin.get(SelectBoxStyle.class));
magFilter.setItems("Nearest", "Linear");
Table table = new Table();
table.setSize(ui.getWidth(), 30);
table.setY(ui.getHeight() - 30);
table.add(hwMipMap).spaceRight(5);
table.add(new Label("Min Filter", skin)).spaceRight(5);
table.add(minFilter).spaceRight(5);
table.add(new Label("Mag Filter", skin)).spaceRight(5);
table.add(magFilter);
ui.addActor(table);
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!