com.badlogic.gdx.utils.Scaling Java Examples
The following examples show how to use
com.badlogic.gdx.utils.Scaling.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SlotActor.java From Cubes with MIT License | 6 votes |
public SlotActor(Inventory inventory, int num) { super(new ButtonStyle()); Image image = new Image(); image.setScaling(Scaling.fit); image.setDrawable(new SlotDrawable()); image.setTouchable(Touchable.disabled); add(image); setSize(getPrefWidth(), getPrefHeight()); this.inventory = inventory; this.num = num; InventoryManager.newSlot(this); addListener(new SlotTooltipListener(this)); }
Example #2
Source File: SceneFitViewport.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@Override public void update (int screenWidth, int screenHeight, boolean centerCamera) { Vector2 scaled = Scaling.fit.apply(getWorldWidth(), getWorldHeight(), screenWidth, screenHeight); setScreenSize(Math.round(scaled.x), Math.round(scaled.y)); // center the viewport in the middle of the screen setScreenPosition((screenWidth - getScreenWidth()) / 2, (screenHeight - getScreenHeight()) / 2); apply(centerCamera); }
Example #3
Source File: VisImageButton.java From vis-ui with Apache License 2.0 | 6 votes |
private void init () { image = new Image(); image.setScaling(Scaling.fit); add(image); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisImageButton.this); return false; } }); updateImage(); }
Example #4
Source File: AbilityIconCounter.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
public AbilityIconCounter(Ability ability, int value) { if (ability == null) { ability = Config.abilities.get("skip-turn"); } image = new Image(Config.skin.getDrawable("ability/" + ability.name + "-icon")); if (ability.cost <0) image.setColor(AbilityIcon.unique); image.setScaling(Scaling.none); image.setAlign(Align.left | Align.top); image.moveBy(0, 1); counter = new Label("", Config.skin, "default", "inventory-counter"); counter.setAlignment(Align.right | Align.bottom); setCount(value); addActor(image); addActor(counter); setSize(image.getPrefWidth(), image.getPrefHeight()); }
Example #5
Source File: VisImageTextButton.java From vis-ui with Apache License 2.0 | 6 votes |
private void init (String text) { defaults().space(3); image = new Image(); image.setScaling(Scaling.fit); add(image); label = new Label(text, new LabelStyle(style.font, style.fontColor)); label.setAlignment(Align.center); add(label); setStyle(style); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisImageTextButton.this); return false; } }); }
Example #6
Source File: ExpandEditTextButton.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
public ExpandEditTextButton(String text, Style style) { super(style); this.style = style; label = new VisLabel(text, style.labelStyle); label.setAlignment(Align.left); label.setEllipsis(true); labelCell = add(label).growX().left().width(new LabelCellWidthValue()); if (style.expandIcon != null) { Image image = new Image(style.expandIcon); image.setScaling(Scaling.none); expandIconCell = add(image).padLeft(4f); } }
Example #7
Source File: GLTFDemoUI.java From gdx-gltf with Apache License 2.0 | 5 votes |
public void setImage(Texture texture){ if(texture != null){ Image img = new Image(texture); img.setScaling(Scaling.fit); screenshotsTable.add(img).height(100); } }
Example #8
Source File: CardDeckApplication.java From androidsvgdrawable-plugin with Apache License 2.0 | 5 votes |
private void initializeAssets() { skin = manager.get("skin.json", Skin.class); atlas = manager.get("skin.atlas", TextureAtlas.class); // layout Table table = new Table(); table.pad(10); table.defaults().space(10); table.setFillParent(true); // header table.row(); table.add(new Label("LibGDX Card Deck", skin, "cantarell")).colspan(RANKS.length); // deck for (String suit : SUITS) { table.row(); for (String rank : RANKS) { table.add( new Image( new SpriteDrawable(atlas.createSprite(String.format("card1_suit_%s_rank_%s", suit, rank))), Scaling.fit)); } } stage.addActor(table); }
Example #9
Source File: SplashMenu.java From Cubes with MIT License | 5 votes |
public SplashMenu() { logo = new Image(new TextureRegionDrawable(Assets.getTextureRegion("core:logo.png")), Scaling.fillY, Align.center); text = new Label("Loading " + Branding.DEBUG, new Label.LabelStyle(Fonts.smallHUD, Color.WHITE)); stage.addActor(logo); stage.addActor(text); }
Example #10
Source File: TabbedPane.java From vis-ui with Apache License 2.0 | 5 votes |
public TabButtonTable (Tab tab) { this.tab = tab; button = new VisTextButton(getTabTitle(tab), style.buttonStyle) { @Override public void setDisabled (boolean isDisabled) { super.setDisabled(isDisabled); closeButton.setDisabled(isDisabled); deselect(); } }; button.setFocusBorderEnabled(false); button.setProgrammaticChangeEvents(false); closeButtonStyle = new VisImageButtonStyle(VisUI.getSkin().get("close", VisImageButtonStyle.class)); closeButton = new VisImageButton(closeButtonStyle); closeButton.setGenerateDisabledImage(true); closeButton.getImage().setScaling(Scaling.fill); closeButton.getImage().setColor(Color.RED); addListeners(); buttonStyle = new VisTextButtonStyle((VisTextButtonStyle) button.getStyle()); button.setStyle(buttonStyle); closeButtonStyle = closeButton.getStyle(); up = buttonStyle.up; add(button); if (tab.isCloseableByUser()) { add(closeButton).size(14 * sizes.scaleFactor, button.getHeight()); } }
Example #11
Source File: GameStage.java From martianrun with Apache License 2.0 | 5 votes |
public GameStage() { super(new ScalingViewport(Scaling.stretch, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT))); setUpCamera(); setUpStageBase(); setUpGameLabel(); setUpMainMenu(); setUpTouchControlAreas(); Gdx.input.setInputProcessor(this); AudioUtils.getInstance().init(); onGameOver(); }
Example #12
Source File: ZoneEntryDisplayer.java From riiablo with Apache License 2.0 | 5 votes |
@Override protected void initialize() { entryImage = new DCWrapper(); entryImage.setScaling(Scaling.none); entryImage.setAlign(Align.center); entryImage.setBlendMode(BlendMode.DARKEN); entryImage.setColor(Riiablo.colors.darkenRed); entryImage.setVisible(false); stage.addActor(entryImage); }
Example #13
Source File: DieSettingsWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void updateChangeNameButton(Button button, Params params) { final Item coin = Config.items.get("coin"); button.setDisabled(params.die.renames == 0 && params.userData.getItemCount(coin) == 0); button.clearChildren(); if (params.die.renames == 0) { button.add(new LocLabel("ui-change-name-for")).padLeft(4); Image image = new Image(Config.skin, "item/coin"); image.setScaling(Scaling.none); button.add(image).padTop(0).padBottom(-4); button.add("1").padRight(4); } else { button.add(new LocLabel("ui-change-name")); } }
Example #14
Source File: CreatureQueueWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override protected void initialize() { creaturesList.defaults().pad(2); creaturesList.padTop(12); Image left = new Image(Config.skin, "ui-creature-queue-gradient-left"); left.setScaling(Scaling.stretchY); left.setAlign(Align.left); left.setTouchable(Touchable.disabled); Image right = new Image(Config.skin, "ui-creature-queue-gradient-right"); right.setScaling(Scaling.stretchY); right.setAlign(Align.right); right.setTouchable(Touchable.disabled); Stack stack = new Stack(); stack.add(new ScrollPane(creaturesList, new ScrollPane.ScrollPaneStyle())); stack.add(left); stack.add(right); Table content = new Table(Config.skin); content.setTouchable(Touchable.enabled); content.setBackground("ui-inventory-ability-window-background"); content.defaults().pad(2); content.add(new LocLabel("ui-turns-order")).row(); content.add(new Image(Config.skin, "ui-creature-info-line")).width(100).row(); content.add(stack).maxWidth(table.getStage().getWidth() - 45).padRight(4).padLeft(4).row(); table.add(content); }
Example #15
Source File: ImageScalingUndoable.java From skin-composer with MIT License | 5 votes |
public ImageScalingUndoable(Scaling scaling) { this.scaling = scaling; dialog = DialogSceneComposer.dialog; image = (DialogSceneComposerModel.SimImage) dialog.simActor; if (scaling != null && scaling.equals("")) { this.scaling = null; } previousScaling = image.scaling; }
Example #16
Source File: GLTFDemoUI.java From gdx-gltf with Apache License 2.0 | 5 votes |
private void addMaterialTextureSwitch(String name, final Material material, long type){ final PBRTextureAttribute attribute = material.get(PBRTextureAttribute.class, type); if(attribute != null){ final TextButton bt = new TextButton(name, getSkin(), "toggle"); bt.setChecked(true); materialTable.add(bt); Image pict = new Image(attribute.textureDescription.texture); pict.setScaling(Scaling.fit); materialTable.add(pict).size(64); materialTable.row(); bt.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if(bt.isChecked()){ material.set(attribute); }else{ material.remove(attribute.type); } } }); } }
Example #17
Source File: SourceImage.java From gdx-texture-packer-gui with Apache License 2.0 | 4 votes |
public SourceImage(Pixmap pixmap) { this.pixmap = pixmap; image = new Image(); image.setScaling(Scaling.stretch); addActor(image); }
Example #18
Source File: TImage.java From cocos-ui-libgdx with Apache License 2.0 | 4 votes |
public TImage(Drawable drawable, Scaling scaling, int align) { super(drawable, scaling, align); init(); }
Example #19
Source File: TImage.java From cocos-ui-libgdx with Apache License 2.0 | 4 votes |
public TImage(Drawable drawable, Scaling scaling) { super(drawable, scaling); init(); }
Example #20
Source File: VisImage.java From vis-ui with Apache License 2.0 | 4 votes |
public VisImage (Drawable drawable, Scaling scaling) { super(drawable, scaling); }
Example #21
Source File: VisImage.java From vis-ui with Apache License 2.0 | 4 votes |
public VisImage (Drawable drawable, Scaling scaling, int align) { super(drawable, scaling, align); }
Example #22
Source File: Editor.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
@Override public void create() { if (EditorLogger.debugMode()) { EngineLogger.setDebug(); } Gdx.graphics.setWindowedMode(Math.max((int) (Gdx.graphics.getDisplayMode().width * 0.9), 1920 / 2), Math.max((int) (Gdx.graphics.getDisplayMode().height * 0.9), 1080 / 2)); skin = new BladeSkin(Gdx.files.internal(SKIN)); VisUI.load(); FileChooser.setDefaultPrefsName("com.bladecoder.engineeditor.filechooser"); /*** STAGE SETUP ***/ stage = new Stage(new ScreenViewport()); Gdx.input.setInputProcessor(stage); setCtx(); Message.init(skin); scnEditor = new ScnEditor(skin); scnEditor.setBackground("background"); skin.getFont("default-font").getData().markupEnabled = true; // RIGHT PANEL ScenePanel scenePanel = new ScenePanel(skin); ActorPanel actorPanel = new ActorPanel(skin); Table rightPanel = new Table(skin); rightPanel.top().left(); rightPanel.add(actorPanel).expand().fill().left(); rightPanel.setBackground("background"); SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin); splitPaneRight.setSplitAmount(0.75f); // LEFT PANEL ProjectPanel projectPanel = new ProjectPanel(skin); Image img = new Image(Ctx.assetManager.getIcon("title")); img.setScaling(Scaling.none); img.setAlign(Align.left); Table leftPanel = new Table(skin); leftPanel.top().left().padLeft(10); leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(0).left(); leftPanel.row(); leftPanel.add(new ProjectToolbar(skin)).expandX().fill().left(); leftPanel.row(); leftPanel.add(projectPanel).expand().fill().left(); leftPanel.row(); leftPanel.add(scenePanel).expand().fill().left(); leftPanel.setBackground("background"); SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin); splitPaneLeft.setFillParent(true); splitPaneLeft.setSplitAmount(0.25f); stage.addActor(splitPaneLeft); // LOAD LAST OPEN PROJECT String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, ""); final File lastProjectFile = new File(lastProject); if (!lastProject.isEmpty() && lastProjectFile.exists()) { EditorLogger.debug("Loading previous project: " + lastProject); try { EditorUtils.checkVersionAndLoadProject(lastProjectFile, stage, skin); } catch (Exception e) { EditorLogger.error("Error loading previous project.", e); Ctx.project.closeProject(); } } stage.setScrollFocus(scnEditor.getScnWidget()); stage.setKeyboardFocus(scnEditor.getScnWidget()); // TooltipManager.getInstance().instant(); TooltipManager.getInstance().initialTime = 0.2f; TooltipManager.getInstance().hideAll(); TooltipManager.getInstance().subsequentTime = 0.2f; }
Example #23
Source File: DialogSceneComposerEvents.java From skin-composer with MIT License | 4 votes |
public void imageScaling(Scaling scaling) { processUndoable(new ImageScalingUndoable(scaling)); }
Example #24
Source File: GdxImage.java From libGDX-Path-Editor with Apache License 2.0 | 4 votes |
public GdxImage(Texture t, String name) { super(t, Scaling.none, Align.CENTER, name); }