List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Image setDrawable
public void setDrawable(Drawable drawable)
From source file:com.agateau.pixelwheels.racescreen.FinishedOverlay.java
License:Open Source License
private void fillBestRow(UiBuilder builder, int row, int rank, String text) { Image image = builder.getActor("bestImage" + String.valueOf(row)); Label label = builder.getActor("bestLabel" + String.valueOf(row)); TextureRegion region = mGame.getAssets().ui.atlas.findRegion("best-" + String.valueOf(rank + 1)); image.setDrawable(new TextureRegionDrawable(region)); image.pack();/*w w w . j a v a 2s. c o m*/ label.setText(text); label.pack(); }
From source file:com.agateau.pixelwheels.screens.PwStageScreen.java
License:Open Source License
public PwStageScreen(UiAssets uiAssets) { super(new ScalingViewport(Scaling.fit, WIDTH, HEIGHT)); Image image = new Image(); image.setDrawable(new TiledDrawable(uiAssets.background)); image.setFillParent(true);//from w w w . j a v a 2 s .com getStage().addActor(image); }
From source file:com.agateau.ui.UiBuilder.java
License:Apache License
private void initImageFromNinePatchName(Image image, TextureAtlas atlas, String name) { NinePatch patch = atlas.createPatch(name.substring(0, name.length() - 2)); image.setDrawable(new NinePatchDrawable(patch)); }
From source file:com.agateau.ui.UiBuilder.java
License:Apache License
private void initImageFromRegionName(Image image, TextureAtlas atlas, String name, boolean tiled) { TextureRegion region = atlas.findRegion(name); Assert.check(region != null, "No region named " + name); Drawable drawable;/*from w w w. j a va 2s . co m*/ if (tiled) { drawable = new TiledDrawable(region); } else { drawable = new TextureRegionDrawable(region); } image.setDrawable(drawable); if (image.getWidth() == 0) { image.setWidth(region.getRegionWidth()); } if (image.getHeight() == 0) { image.setHeight(region.getRegionHeight()); } }
From source file:com.alterego.jelly.screens.PlayGameScreen.java
License:Apache License
private void dropStar(Image img) { stars--;/*from w w w . ja v a2s .c om*/ img.setDrawable(new TextureRegionDrawable(Assets.instance.gameElements.starOff)); star.setPosition(img.getX() - 45, img.getY() - 50); star.addAction(Actions.sequence(Actions.scaleTo(0.3f, 0.3f), Actions.alpha(1f), Actions.parallel(Actions.rotateBy(210f, 0.9f), Actions.scaleTo(0.8f, 0.8f, 0.9f), Actions.moveTo(star.getX() - 45f, star.getY() - 210f, 1.2f), Actions.alpha(0f, 0.9f, Interpolation.circleIn)))); }
From source file:com.nhydock.storymode.scenes.title.TitleSequence.java
@Override public void init() { final TitleSequence ui = this; // create title sequence final Skin skin = manager.get(DataDirs.Home + "title.json", Skin.class); final Skin uiskin = shared.getResource(DataDirs.Home + "uiskin.json", Skin.class); //clouds/* ww w . ja v a2 s . c o m*/ { Image goddess = new Image(uiskin, "goddess"); goddess.setSize(32, 32); goddess.setPosition(getWidth(), getHeight() - 96f); goddess.setOrigin(Align.center); addActor(goddess); Image cloudsPan1 = new Image(new TiledDrawable(uiskin.getRegion("clouds"))); Image cloudsPan2 = new Image(new TiledDrawable(uiskin.getRegion("clouds"))); cloudsPan1.setWidth(getWidth() * 5); cloudsPan2.setWidth(getWidth() * 5); cloudsPan1.setPosition(0, 0, Align.topLeft); cloudsPan2.setPosition(0, 0, Align.topLeft); addActor(cloudsPan1); addActor(cloudsPan2); cloudsPan1.addAction(Actions.sequence(Actions.moveToAligned(getWidth(), 0, Align.topRight), Actions.delay(10f), Actions.parallel(Actions.moveBy(0, 140f, 3f, Interpolation.sineOut), Actions.moveBy(getWidth() * 5, 0, 50f)))); cloudsPan2.addAction(Actions.sequence(Actions.moveToAligned(getWidth(), 0, Align.topRight), Actions.delay(10f), Actions.parallel(Actions.moveBy(0, 80f, 3f, Interpolation.sineOut), Actions.moveBy(getWidth() * 5, 0, 40f)))); goddess.addAction(Actions.sequence(Actions.delay(20f), Actions.parallel(Actions.repeat(5, Actions.rotateBy(360, .4f)), Actions.moveBy(-getWidth() - 32, 0f, 2f)), Actions.delay(1f), Actions.addAction(Actions.moveBy(0, getHeight(), 1f, Interpolation.sineIn), cloudsPan1), Actions.addAction(Actions.moveBy(0, getHeight(), 1f, Interpolation.sineIn), cloudsPan2))); } // initial text { Table textGrid = new Table(); textGrid.setFillParent(true); textGrid.pad(40f); Label text = new Label( "This game is Shareware!\n\nThat means it's completely free to download and distribute.\n\nIf you'd like to be nice, you can donate and learn more at http://nhydock.github.io/Storymode", skin); text.setWrap(true); text.setAlignment(Align.center); text.addAction(Actions.sequence(Actions.alpha(0f), Actions.alpha(1f, 1f))); textGrid.add(text).expandX().fillX(); text = new Label("~Thanks a bunch!", skin); text.setWrap(true); text.setAlignment(Align.right); text.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(3f), Actions.alpha(1f, 1f))); textGrid.row(); textGrid.add(text).expandX().fillX().padRight(60f); textGrid.addAction(Actions.sequence(Actions.alpha(1f), Actions.delay(8f), Actions.alpha(0f, 2f), Actions.run(new PlayBGM(manager.get(DataDirs.Audio + "title.mp3", Music.class))))); addActor(textGrid); } // credits animation { Table textGrid = new Table(); textGrid.setFillParent(true); textGrid.pad(40f); Label text = new Label("Graphics, Programming, Project Lead", skin); text.setAlignment(Align.center); textGrid.add(text).expandX().fillX(); textGrid.row(); text = new Label("Nicholas Hydock", skin); text.setAlignment(Align.center); textGrid.add(text).expandX().fillX(); textGrid.row(); text = new Label(" ", skin); text.setAlignment(Align.center); textGrid.add(text).expandX().fillX(); textGrid.row(); text = new Label("Ideas, Suggestions, Emotional Support, & Bros4Lyfe", skin); text.setAlignment(Align.center); textGrid.add(text).expandX().fillX(); textGrid.row(); text = new Label("Patrick Flanagan", skin); text.setAlignment(Align.center); textGrid.add(text).expandX().fillX(); textGrid.row(); text = new Label("Matthew Hydock", skin); text.setAlignment(Align.center); textGrid.add(text).expandX().fillX(); textGrid.row(); text = new Label("Andrew Hoffman", skin); text.setAlignment(Align.center); textGrid.add(text).expandX().fillX(); textGrid.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(10f), Actions.alpha(1f, .75f), Actions.delay(4f), Actions.alpha(0f, .75f))); addActor(textGrid); } // display tool logos { Group group = new Group(); Image tools = new Image(skin.getDrawable("tools")); tools.setPosition(getWidth() / 2 - tools.getWidth() / 2, getHeight() / 2 - tools.getHeight() / 2); Label label = new Label( "All music is licensed under Creative-Commons BY(-NC) or other permissive licenses.\nAll attribution can be found in the README", skin, "small"); label.setPosition(getWidth() / 2f, getHeight() / 2f - 80f, Align.top); label.setAlignment(Align.center); group.addActor(tools); group.addActor(label); group.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(16f), Actions.alpha(1f, .75f), Actions.delay(4f), Actions.alpha(0f, .75f))); addActor(group); } // cool animation { Group cool = new Group(); cool.setSize(getWidth(), getHeight()); Group group = new Group(); Image cliff = new Image(skin.getRegion("cliff")); group.addAction(Actions.sequence(Actions.moveTo(0, -cliff.getHeight()), Actions.delay(24f), Actions.moveTo(0, 0, 4f))); group.addActor(cliff); final Image character = new Image(skin.getRegion("back")); character.setSize(96f, 96f); group.addActor(character); character.addAction( Actions.sequence(Actions.moveTo(200f, 200f), Actions.delay(31f), Actions.run(new Runnable() { @Override public void run() { character.setDrawable(skin.getDrawable("character")); } }), Actions.moveTo(-character.getWidth() / 2, -character.getHeight(), 1f), Actions.delay(10f), Actions.run(new Runnable() { @Override public void run() { character.setDrawable(skin.getDrawable("back")); } }), Actions.moveTo(200f, 200f, 1f), Actions.delay(.2f), Actions.run(new Runnable() { @Override public void run() { character.setDrawable(skin.getDrawable("character")); } }))); Image castle = new Image(skin.getRegion("castle")); castle.addAction( Actions.sequence(Actions.moveToAligned(getWidth() - castle.getWidth(), 0f, Align.topLeft), Actions.delay(24f), Actions.moveBy(0, getHeight(), 4f))); Image lightning = new Image(skin.getRegion("lightning")); lightning.setPosition(getWidth() - castle.getWidth(), getHeight() - castle.getHeight()); lightning.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(29f), Actions.alpha(1f, .1f), Actions.delay(.3f), Actions.alpha(.3f, .3f), Actions.alpha(1f, .1f), Actions.delay(.3f), Actions.alpha(0f, 1f))); Image logo = new Image(skin.getRegion("logo")); logo.addAction(Actions.sequence(Actions.alpha(0f), Actions.moveTo(0, getHeight() - logo.getHeight() + 5f), Actions.delay(34f), Actions.alpha(1f, 1f), Actions.forever(Actions.sequence(Actions.moveTo(0, getHeight() - logo.getHeight() + 5f, 2f), Actions.moveTo(0, getHeight() - logo.getHeight() - 5f, 2f))))); Table table = new Table(); Label label = new Label("Title theme", skin, "small"); label.setAlignment(Align.right); table.add(label).expandX().fillX(); table.row(); label = new Label("Anamanaguchi - Helix Nebula", skin, "small"); label.setAlignment(Align.right); table.add(label).expandX().fillX(); table.row(); table.pad(10f); table.pack(); table.addAction(Actions.sequence(Actions.alpha(0f), Actions.moveTo(getWidth() - table.getWidth(), 0), Actions.delay(40f), Actions.alpha(1f, 1f))); cool.addActor(castle); cool.addActor(lightning); cool.addActor(group); cool.addActor(logo); cool.addActor(table); cool.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(24f), Actions.alpha(1f), Actions.delay(40f), Actions.alpha(0f, 1f), Actions.delay(1f), Actions.run(new Runnable() { @Override public void run() { SceneManager.switchToScene("title"); } }), Actions.delay(1.5f), Actions.run(new Runnable() { @Override public void run() { } }))); addActor(cool); final Label startLabel = new Label("Press Start", skin); startLabel.setPosition(getWidth() - 360f, 120f); startLabel.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(38f), Actions.alpha(1f, .3f), Actions.run(new Runnable() { @Override public void run() { ui.addListener(new InputListener() { @Override public boolean touchDown(InputEvent evt, float x, float y, int pointer, int button) { if (button == Buttons.LEFT) { SceneManager.switchToScene("newgame"); return true; } return false; } }); } }), Actions.delay(24f), Actions.alpha(0f, 1f))); addActor(startLabel); } // make sure all initial steps are set act(); addListener(new InputListener() { @Override public boolean keyDown(InputEvent evt, int keycode) { // skip the intro if (Input.ACCEPT.match(keycode) || Input.CANCEL.match(keycode)) { SceneManager.switchToScene("newgame"); return true; } return false; } @Override public boolean touchDown(InputEvent evt, float x, float y, int pointer, int button) { if (button == Buttons.RIGHT) { SceneManager.switchToScene("newgame"); return true; } return false; } }); }
From source file:com.ore.infinium.HotbarInventoryView.java
License:Open Source License
@Override public void set(byte index, Inventory inventory) { SlotElement slot = m_slots[index];// www . j a v a2 s. c o m Entity item = inventory.item(index); ItemComponent itemComponent = itemMapper.get(item); m_slots[index].itemCountLabel.setText(Integer.toString(itemComponent.stackSize)); TextureRegion region; SpriteComponent spriteComponent = spriteMapper.get(item); if (blockMapper.get(item) != null) { //hack region = m_client.m_world.m_tileRenderer.m_tilesAtlas .findRegion(spriteComponent.textureName.concat("-00")); } else { region = m_client.m_world.m_atlas.findRegion(spriteComponent.textureName); } Image slotImage = slot.itemImage; // //m_blockAtlas.findRegion("stone")); slotImage.setDrawable(new TextureRegionDrawable(region)); slotImage.setSize(region.getRegionWidth(), region.getRegionHeight()); slotImage.setScaling(Scaling.fit); setHotbarSlotVisible(index, true); //do not exceed the max size/resort to horrible upscaling. prefer native size of each inventory sprite. //.maxSize(region.getRegionWidth(), region.getRegionHeight()).expand().center(); }
From source file:com.redtoorange.game.ui.missionui.HealthUI.java
License:Open Source License
/** Determine the current state of the health, low, medium or high. */ private void determineState() { if (.66 <= ((float) currentHealth / maxHealth)) { if (currentState != HealthState.HIGH) { currentState = HealthState.HIGH; for (Image i : healthMeter) { i.setDrawable(new TextureRegionDrawable(healthBars.findRegion("highHealth"))); }/*from w ww .j a va 2 s .com*/ } } else if (.33 <= ((float) currentHealth / maxHealth)) { if (currentState != HealthState.MEDIUM) { currentState = HealthState.MEDIUM; for (Image i : healthMeter) { i.setDrawable(new TextureRegionDrawable(healthBars.findRegion("mediumHealth"))); } } } else if (.0 <= ((float) currentHealth / maxHealth)) { if (currentState != HealthState.LOW) { currentState = HealthState.LOW; for (Image i : healthMeter) { i.setDrawable(new TextureRegionDrawable(healthBars.findRegion("lowHealth"))); } } } }
From source file:es.eucm.ead.editor.ui.scenes.map.SceneWidget.java
License:Open Source License
public SceneWidget(Controller control, String sceneId) { super(control.getApplicationAssets().getSkin()); defaults().expand().fill();//from w w w . j a va2 s. c o m this.controller = control; this.sceneId = sceneId; Model model = controller.getModel(); this.scene = (ModelEntity) model.getResourceObject(sceneId, ResourceCategory.SCENE); Skin skin = controller.getApplicationAssets().getSkin(); final Image image = new Image(); image.setScaling(Scaling.fit); controller.getEditorGameAssets().get(Q.getThumbnailPath(scene), Texture.class, new AssetLoadedCallback<Texture>() { @Override public void loaded(String fileName, Texture asset) { image.setDrawable(new TextureRegionDrawable(new TextureRegion(asset))); } @Override public void error(String fileName, Class type, Throwable exception) { } }); Documentation documentation = Q.getComponent(scene, Documentation.class); String name = documentation.getName(); this.name = new Label(name == null ? sceneId : name, skin); this.name.setAlignment(Align.bottom | Align.center); initial = new Image(skin.getDrawable("mirrory24x24")); initial.setScaling(Scaling.none); GameData component = Q.getComponent(model.getGame(), GameData.class); String initialScene = component.getInitialScene(); setInitial(initialScene != null && initialScene.equals(sceneId)); model.addFieldListener(component, initialSceneListener); Object modelEntity = model.getSelection().getSingle(Selection.SCENE); setChecked(modelEntity == scene); Table topRow = new Table(); topRow.add(initial).top().left().expand(); stack(image, topRow); row(); add(this.name); pad(PAD); }
From source file:es.eucm.ead.editor.view.builders.scene.context.GroupContext.java
License:Open Source License
protected void addIcon(String id, Drawable drawable) { Image image = new Image(); image.setDrawable(drawable); Container<Image> imageContainer = new Container<Image>().size(WidgetBuilder.dpToPixels(12)); imageContainer.setActor(image);//from w w w .j a va 2 s. com imageContainer.setName(id); iconsList.add(imageContainer).centerX(); }