List of usage examples for com.badlogic.gdx.utils Scaling stretch
Scaling stretch
To view the source code for com.badlogic.gdx.utils Scaling stretch.
Click Source Link
From source file:com.axatrikx.solor.view.SplashScreen.java
License:Apache License
@Override public void show() { super.show(); // start playing the menu music // game.getMusicManager().play(SolorMusic.MENU); TextureRegion splashRegion = new TextureRegion(new Texture("images/splash.png"), 0, 0, 512, 301); Drawable splashDrawable = new TextureRegionDrawable(splashRegion); // here we create the splash image actor; its size is set when the // resize() method gets called splashImage = new Image(splashDrawable, Scaling.stretch); splashImage.setFillParent(true);/*from ww w .ja va 2 s.c o m*/ // this is needed for the fade-in effect to work correctly; we're just // making the image completely transparent splashImage.getColor().a = 0f; // configure the fade-in/out effect on the splash image splashImage.addAction(sequence(fadeIn(0.75f), delay(1.75f, fadeOut(0.75f)), new Action() { @Override public boolean act(float delta) { // the last action will move to the next screen game.setScreen(game.getMenuScreen()); return true; } })); // and finally we add the actor to the stage stage.addActor(splashImage); }
From source file:com.bagon.matchteam.mtx.screen.AbstractScreen.java
License:Apache License
/** * Set stage background. Sets the image (Adds to stage as image) * /*from w w w . ja va 2 s. c om*/ * @param backgroundTextureRegion * * */ public void setBackgroundTexture(TextureRegion textureBackground) { Drawable tBg = new TextureRegionDrawable(textureBackground); Image imgbg = new Image(tBg, Scaling.stretch); imgbg.setFillParent(true); stage.addActor(imgbg); // MtxLogger.log(logActive, true, logTag, "SCREEN BG IMAGE SET: " + getScreenName()); }
From source file:com.gamestudio24.martianrun.stages.GameStage.java
License:Apache License
public GameStage() { super(new ScalingViewport(Scaling.stretch, VIEWPORT_WIDTH, VIEWPORT_HEIGHT, new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT))); setUpCamera();/* ww w. j ava2s .c o m*/ setUpStageBase(); setUpGameLabel(); setUpMainMenu(); setUpTouchControlAreas(); Gdx.input.setInputProcessor(this); AudioUtils.getInstance().init(); onGameOver(); }
From source file:com.jlabarca.director.Scene.java
License:Apache License
/** * Constructor where we supply our own sprite batch. * /*from www . j a v a 2 s .c om*/ * @param width * @param height * @param stretch * @param batch */ public Scene(float width, float height, boolean stretch, Batch batch) { super(new ScalingViewport(Scaling.stretch, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new OrthographicCamera()), batch); //super(); inputMultiplexer = new InputMultiplexer(this); nodes = new Array<Node>(DEFAULT_LAYER_CAPACITY); }
From source file:com.luongbui.gdx.libpd.pianotest.screen.PianoScreen.java
License:Apache License
@Override public void resize(int width, int height) { Vector2 size = Scaling.stretch.apply(WIDTH_VIRTUAL, HEIGHT_VIRTUAL, width, height); viewportX = MathUtils.ceilPositive(width - size.x) / 2; viewportY = MathUtils.ceilPositive(height - size.y) / 2; viewportWidth = MathUtils.floorPositive(size.x); viewportHeight = MathUtils.floorPositive(size.y); Gdx.gl.glViewport(viewportX, viewportY, viewportWidth, viewportHeight); stage.setViewport(WIDTH_VIRTUAL, HEIGHT_VIRTUAL, true, viewportX, viewportY, viewportWidth, viewportHeight); }
From source file:com.netthreads.libgdx.director.Director.java
License:Apache License
public Viewport getViewPort() { return new ScalingViewport(Scaling.stretch, width, height, new OrthographicCamera()); }
From source file:com.ray3k.skincomposer.dialog.DialogDrawables.java
License:Open Source License
private void refreshDrawableDisplay() { contentGroup.clear();// w w w .j a va2s . c om TooltipManager manager = new TooltipManager(); manager.animations = false; manager.initialTime = .4f; manager.resetTime = 0.0f; manager.subsequentTime = 0.0f; manager.hideAll(); manager.instant(); if (drawables.size == 0) { Label label = new Label("No drawables have been added!", getSkin()); contentGroup.addActor(label); } for (DrawableData drawable : drawables) { Button drawableButton; if (property != null) { drawableButton = new Button(getSkin(), "color-base"); drawableButton.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { result(drawable); hide(); } }); drawableButton.addListener(main.getHandListener()); } else { drawableButton = new Button(getSkin(), "color-base-static"); } contentGroup.addActor(drawableButton); Table table = new Table(); drawableButton.add(table).width(sizes[MathUtils.floor(zoomSlider.getValue())]) .height(sizes[MathUtils.floor(zoomSlider.getValue())]); ClickListener fixDuplicateTouchListener = new ClickListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { event.setBubbles(false); return super.touchDown(event, x, y, pointer, button); } }; //color wheel Button button = new Button(getSkin(), "colorwheel"); button.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { newTintedDrawable(drawable); event.setBubbles(false); } }); button.addListener(fixDuplicateTouchListener); if (property == null) { button.addListener(main.getHandListener()); } table.add(button); //swatches button = new Button(getSkin(), "swatches"); button.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { colorSwatchesDialog(drawable); event.setBubbles(false); } }); button.addListener(fixDuplicateTouchListener); if (property == null) { button.addListener(main.getHandListener()); } table.add(button); //rename (ONLY FOR TINTS) if (drawable.tint != null || drawable.tintName != null) { button = new Button(getSkin(), "settings-small"); button.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { renameDrawableDialog(drawable); event.setBubbles(false); } }); button.addListener(fixDuplicateTouchListener); if (property == null) { button.addListener(main.getHandListener()); } table.add(button); } else { table.add(); } //delete button = new Button(getSkin(), "delete-small"); button.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { deleteDrawable(drawable); event.setBubbles(false); } }); button.addListener(fixDuplicateTouchListener); if (property == null) { button.addListener(main.getHandListener()); } table.add(button).expandX().right(); //preview table.row(); Container bg = new Container(); bg.setClip(true); bg.setBackground(getSkin().getDrawable("white")); bg.setColor(drawable.bgColor); Image image = new Image(drawablePairs.get(drawable)); if (MathUtils.isZero(zoomSlider.getValue())) { image.setScaling(Scaling.fit); bg.fill(false); } else { image.setScaling(Scaling.stretch); bg.fill(); } bg.setActor(image); table.add(bg).colspan(4).grow(); //name table.row(); Label label = new Label(drawable.name, getSkin()); label.setEllipsis("..."); label.setEllipsis(true); label.setAlignment(Align.center); table.add(label).colspan(4).growX().width(sizes[MathUtils.floor(zoomSlider.getValue())]); //Tooltip TextTooltip toolTip = new TextTooltip(drawable.name, manager, getSkin()); label.addListener(toolTip); } }
From source file:com.sawan.mathattack.game.layers.WorldLayerBG.java
License:Open Source License
/** * Sets the up backround. */ private void setUpBackround() { setBackgroundTexture(MALevelAssets.sky, Scaling.stretch, true, false); }
From source file:com.strategames.catchdastars.dialogs.LevelCompleteDialog.java
License:Open Source License
private void showScoreActor() { if (!scoreItemIterator.hasNext()) { //start next animation phase animationController();//from www . jav a2 s . c o m return; } Score.ScoreItem scoreItem = scoreItemIterator.next(); final int increment = scoreItem.getMultiplier(); final int amount = scoreItem.getScore(); final SoundEffect incrementSound = SoundEffect.getSoundForIncrement(increment); Image image = scoreItem.getImage(); image.setScaling(Scaling.stretch); double scaleFactor = this.maxImageHeight / (double) image.getHeight(); float height = this.maxImageHeight; float width = (float) (image.getWidth() * scaleFactor); Table scoreItemTable = new Table(); scoreItemTable.add(image).padRight(20f).width(width).height(height); final Label label = new Label("", getSkin()); scoreItemTable.add(label).width(50f); this.animPosition.x = 100f; this.animPosition.y = this.top - ((this.maxImageHeight + this.padding) * scoreActors.size()); scoreItemTable.setPosition(animPosition.x, -height); this.count = 0; this.delayCount = 0; scoreItemTable.addAction( sequence(moveTo(animPosition.x, animPosition.y, 1f, Interpolation.circleOut), new Action() { @Override public boolean act(float delta) { if (count <= amount) { if (delayCount < 1) { label.setText(String.valueOf(count)); if (count > 0) { incrementSound.play(); } count += increment; delayCount = delay; } delayCount--; return false; } else { showScoreActor(); return true; } } })); scoreActors.add(new ScoreActor(scoreItemTable, scoreItem)); super.stage.addActor(scoreItemTable); }
From source file:com.strategames.catchdastars.dialogs.LevelCompleteDialog.java
License:Open Source License
private void showCashRegistry(final float x, final float y) { this.cashRegister = new Table(); final float scale = 1.2f; Image image = new Image(Textures.getInstance().cashRegister); image.setScaling(Scaling.stretch); double scaleFactor = this.maxImageHeight / (double) image.getHeight(); float height = this.maxImageHeight; float width = (float) (image.getWidth() * scaleFactor); float xPosition = x + width; this.cashRegister.add(image).padRight(20f).width(width); this.cashRegister.setTransform(true); this.cashRegister.setHeight(height); this.cashRegister.setPosition(xPosition, -height); this.cashRegister.scaleBy(scale); this.totalScoreLabel = new Label( String.valueOf(this.score.getCumulatedScore() - this.score.getTotalScoreFromScoreItems()), getSkin());/*from w ww .j a v a2 s . c o m*/ this.totalScoreLabel.scaleBy(scale); this.cashRegister.add(totalScoreLabel).width(50); float finalYPosition = y - height - this.padding; this.cashRegister .addAction(sequence(moveTo(xPosition, finalYPosition, 1f, Interpolation.circleOut), new Action() { @Override public boolean act(float delta) { animationController(); return true; } })); super.stage.addActor(this.cashRegister); cashRegisterOpenSound.play(); }