List of usage examples for com.badlogic.gdx.scenes.scene2d.utils TiledDrawable TiledDrawable
public TiledDrawable(TextureRegionDrawable drawable)
From source file:broken.shotgun.throwthemoon.actors.Background.java
License:Open Source License
public Background(AssetManager manager) { manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver())); manager.load(TEXTURE_FILENAME, Texture.class); manager.finishLoading();//from www . ja va 2s .c om texture = manager.get(TEXTURE_FILENAME); TextureRegion[] frames = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0]; animation = new Animation(0.1f, frames[0], frames[1], frames[2]); animation.setPlayMode(PlayMode.LOOP); setWidth(FRAME_WIDTH); setHeight(FRAME_HEIGHT); background = new TiledDrawable(animation.getKeyFrame(0f)); }
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);/*www. j a va 2 s .c o m*/ getStage().addActor(image); }
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 www . j av a 2 s.c o 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.bladecoder.engineeditor.scneditor.ScnWidget.java
License:Apache License
public ScnWidget(Skin skin) { bigFont = skin.get("big-font", BitmapFont.class); defaultFont = skin.get("default-font", BitmapFont.class); setSize(150, 150);//from www . j a v a 2 s . c o m tile = new TiledDrawable(Ctx.assetManager.getIcon("transparent-light")); background = skin.getDrawable("background"); faRenderer.setViewport(getWidth(), getHeight()); setLayoutEnabled(true); addListener(inputListner); Ctx.project.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { EditorLogger.debug("ScnWidget Listener: " + e.getPropertyName()); if (e.getPropertyName().equals(Project.NOTIFY_SCENE_SELECTED)) { if (!projectLoadedFlag) setSelectedScene(Ctx.project.getSelectedScene()); } else if (e.getPropertyName().equals(Project.NOTIFY_ACTOR_SELECTED)) { if (!projectLoadedFlag) setSelectedActor(Ctx.project.getSelectedActor()); } else if (e.getPropertyName().equals(Project.NOTIFY_ANIM_SELECTED)) { if (!projectLoadedFlag && Ctx.project.getSelectedFA() != null) setSelectedFA(Ctx.project.getSelectedFA()); } else if (e.getPropertyName().equals(Project.NOTIFY_PROJECT_LOADED)) { projectLoadedFlag = true; } else if (e.getPropertyName().equals("scene")) { setSelectedScene(Ctx.project.getSelectedScene()); setSelectedActor(Ctx.project.getSelectedActor()); } else if (e.getPropertyName().equals("init_animation")) { if (!inScene) setSelectedFA(null); } } }); }
From source file:com.forerunnergames.peril.client.ui.screens.menus.MenuScreenWidgetFactory.java
License:Open Source License
public Drawable createMenuBarDrawable() { return new TiledDrawable(createTextureRegion(MENU_BAR_DRAWABLE_NAME)); }
From source file:com.jmolina.orb.widgets.game.TiledLayer.java
License:Open Source License
/** * Constructor/*w w w .j a v a 2s.co m*/ * * @param am AssetManager * @param region Regin de textura * @param viewport Viewport */ public TiledLayer(AssetManager am, TextureRegion region, Viewport viewport) { super(am); int viewportTilesX = MathUtils.round(viewport.getWorldWidth() / region.getRegionWidth()); int viewportTilesY = MathUtils.round(viewport.getWorldHeight() / region.getRegionHeight()); TiledDrawable tiledDrawable = new TiledDrawable(region); tiledDrawable.setMinWidth(TIMES_X * viewportTilesX * region.getRegionWidth()); tiledDrawable.setMinHeight(TIMES_Y * viewportTilesY * region.getRegionHeight()); image = new Image(tiledDrawable); image.setPosition(0, 0); addActor(image); }
From source file:com.jmolina.orb.widgets.ui.StaticBackground.java
License:Open Source License
/** * Constructor/*from ww w . j a va 2 s. c om*/ * * @param am AssetManager * @param viewport Viewport */ public StaticBackground(AssetManager am, Viewport viewport) { super(am); TextureRegion region = findRegion(Atlas.UI_BACKGROUND); tiledDrawable = new TiledDrawable(region); tiledDrawable.setMinWidth(viewport.getWorldWidth()); tiledDrawable.setMinHeight(viewport.getWorldHeight()); image = new Image(tiledDrawable); image.setPosition(0, 0); addActor(image); }
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/*from www. j av a 2s.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.vlaaad.dice.states.GameMapState.java
License:Open Source License
private void addItems() { topBackground = new Image(new TiledDrawable(Config.skin.getRegion("ui-top-background"))); topBackground.setSize(stage.getWidth(), topBackground.getPrefHeight()); topBackground.setY(stage.getHeight() - topBackground.getHeight()); itemTable = new Table(Config.skin); itemTable.setFillParent(true);//from w w w .j av a 2 s . c o m itemTable.align(Align.top | Align.left); Array<Item> items = new Array<Item>(); for (Item item : Config.items) { items.add(item); } items.sort(Item.ORDER_COMPARATOR); for (Item item : items) { addItemView(item); } stage.addActor(diceWindowGroup); stage.addActor(topBackground); stage.addActor(itemTable); diceWindowGroup.setSize(stage.getWidth(), topBackground.getY()); diceWindowGroup.setTouchable(Touchable.childrenOnly); }
From source file:de.cubicvoxel.openspacebox.ingame.ui.map.UniverseMap.java
License:Open Source License
public UniverseMap(Collection<Sector.SectorProperties> sectors) { TiledDrawable drawable = new TiledDrawable( new TextureRegion(OpenSpaceBox.getAsset(TextureAsset.UI_UNIVERSEMAP_BACKGROUND))); background = new Image(drawable); background.setFillParent(true);//from w w w. j av a 2s . c om addActor(background); for (Sector.SectorProperties sector : sectors) { SectorButton actor = new SectorButton(sector); actor.addSectorSelectedListener(this::fireSectorSelectedListeners); addActor(actor); } }