com.badlogic.gdx.math.Interpolation Java Examples
The following examples show how to use
com.badlogic.gdx.math.Interpolation.
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: EditableSelectBox.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
public void hide() { if (!list.isTouchable() || !hasParent()) return; list.setTouchable(Touchable.disabled); Stage stage = getStage(); if (stage != null) { stage.removeCaptureListener(hideListener); if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null; Actor actor = stage.getScrollFocus(); if (actor == null || isAscendantOf(actor)) stage.setScrollFocus(previousScrollFocus); } clearActions(); getColor().a = 1; addAction(sequence(fadeOut(0.15f, Interpolation.fade), Actions.removeActor())); }
Example #2
Source File: DropVisualizer.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
@Override public IFuture<Void> visualize(DroppedItem drop) { final Future<Void> future = new Future<Void>(); Group group = new Group(); Tile image = new Tile("item/" + drop.item.name); Label counter = new Label(String.valueOf(drop.count), Config.skin); counter.setSize(image.getWidth(), image.getHeight()); counter.setAlignment(Align.right | Align.bottom); group.addActor(image); group.addActor(counter); group.setTransform(false); visualizer.viewController.notificationLayer.addActor(group); group.setPosition(drop.target.getX() * ViewController.CELL_SIZE, drop.target.getY() * ViewController.CELL_SIZE); group.addAction(Actions.parallel( Actions.moveBy(0, 30, 1f, Interpolation.fade), Actions.alpha(0, 1f, Interpolation.fade), Actions.delay(0.4f, Actions.run(new Runnable() { @Override public void run() { future.happen(); } })) )); return future; }
Example #3
Source File: AttractorModule.java From talos with Apache License 2.0 | 6 votes |
@Override public void processValues() { NumericalValue posNumVal = getScope().get(ScopePayload.PARTICLE_POSITION); pos.set(posNumVal.get(0), posNumVal.get(1)); float alphaVal = getScope().getFloat(ScopePayload.PARTICLE_ALPHA);; if(!alpha.isEmpty()) { alphaVal = alpha.getFloat(); } initialVector.set(initialVelocity.getFloat(), 0); initialVector.rotate(initialAngle.getFloat()); attractionVector.set(attractorPosition.get(0), attractorPosition.get(1)).sub(pos); attractionVector.nor().scl(initialVelocity.getFloat()); Interpolation interpolation = Interpolation.linear; // now let's mix them result.set(interpolation.apply(initialVector.x, attractionVector.x, alphaVal), interpolation.apply(initialVector.y, attractionVector.y, alphaVal)); angle.set(result.angle()); velocity.set(result.len()); }
Example #4
Source File: LocalAchievements.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
private void checkQueue() { if (current != null || queue.size == 0) return; current = queue.removeIndex(0); stage.addActor(current); current.setPosition(stage.getWidth() / 2 - current.getWidth() / 2, stage.getHeight() - current.getHeight() - 10); current.getColor().a = 0; current.addAction(sequence( moveBy(0, current.getHeight() + 10), parallel( alpha(1, 0.5f), moveBy(0, -current.getHeight() - 10, 0.5f, Interpolation.swingOut) ), delay(2.5f), alpha(0, 1f), run(new Runnable() { @Override public void run() { current.remove(); current = null; checkQueue(); } }) )); }
Example #5
Source File: Dialog.java From uracer-kotd with Apache License 2.0 | 6 votes |
/** {@link #pack() Packs} the dialog and adds it to the stage, centered. */ public Dialog show (Stage stage) { clearActions(); removeCaptureListener(ignoreTouchDown); previousKeyboardFocus = null; Actor actor = stage.getKeyboardFocus(); if (actor != null && !actor.isDescendantOf(this)) previousKeyboardFocus = actor; previousScrollFocus = null; actor = stage.getScrollFocus(); if (actor != null && !actor.isDescendantOf(this)) previousScrollFocus = actor; // pack(); setPosition(Math.round((stage.getWidth() - getWidth()) / 2), Math.round((stage.getHeight() - getHeight()) / 2)); stage.addActor(this); stage.setKeyboardFocus(this); stage.setScrollFocus(this); if (fadeDuration > 0) { getColor().a = 0; addAction(Actions.fadeIn(fadeDuration, Interpolation.fade)); } return this; }
Example #6
Source File: SoundManager.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
public void playMusicBeautifully(String name, Stage stage) { final Music music = musics.get(name); if (music == null) { Logger.error("there is no music for " + name); return; } music.setVolume(0); if (!usesMusic) { disabledMusics.add(music); } else { music.play(); } music.setLooping(true); playingMusics.add(music); Action action = new TemporalAction(5f, Interpolation.linear) { @Override protected void update(float percent) { music.setVolume(percent * volume); } }; stage.addAction(action); replaceAction(music, action); }
Example #7
Source File: SoundManager.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
public void stopMusicBeautifully(String name, Stage stage) { final Music music = musics.get(name); if (music == null) { Logger.error("there is no music for " + name); return; } final float initialVolume = music.getVolume(); Action action = new TemporalAction(2f, Interpolation.linear) { @Override protected void update(float percent) { music.setVolume(initialVolume - percent * initialVolume); } @Override protected void end() { music.stop(); playingMusics.remove(music); disabledMusics.remove(music); } }; stage.addAction(action); replaceAction(music, action); }
Example #8
Source File: Message.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@SuppressWarnings("unused") public static void showMsg(final Stage stage, final String text, final boolean modal) { // show in the next frame to allow calling when no OpenGL context is available. Timer.post(new Task() { @Override public void run() { isModal = modal; if (text == null) { hideMsg(); return; } add(stage, text); if (FADE_DURATION > 0) { msg.getColor().a = 0; msg.addAction(Actions.fadeIn(FADE_DURATION, Interpolation.fade)); } } }); }
Example #9
Source File: CanvasContentViewController.java From gdx-vfx with Apache License 2.0 | 6 votes |
@LmlAction("transformVfxCanvas") void transformVfxCanvas() { Actor widgetPanel = widgetsRoot.findActor("cwRightPanel"); widgetPanel.clearActions(); widgetPanel.setOrigin(Align.center); widgetPanel.addAction(Actions.sequence( ActionsExt.transform(true), Actions.scaleTo(1.3f, 1.3f, 0.15f, Interpolation.sineOut), Actions.scaleTo(1f, 1f, 0.75f, Interpolation.elasticOut), ActionsExt.transform(false) )); canvasTransformWrapper.clearActions(); canvasTransformWrapper.setOrigin(Align.center); canvasTransformWrapper.addAction(Actions.sequence( Actions.rotateTo(0f), Actions.scaleTo(1f, 1f), Actions.parallel( Actions.rotateTo(360f, 3f, Interpolation.exp10), Actions.sequence( Actions.scaleTo(0.6f, 0.6f, 1.5f, Interpolation.exp5In), Actions.scaleTo(1.0f, 1.0f, 1.5f, Interpolation.exp5Out) ) ) )); }
Example #10
Source File: PauseMenuStage.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
private void hide() { shown = false; hiding = true; Gdx.input.setInputProcessor(lastInputProcessor); addAction(Actions.sequence( Actions.moveTo(0, Gdx.graphics.getHeight(), 0.5f, Interpolation.swingIn), new RunnableAction() { @Override public void run() { hiding = false; } } )); scorer.resume(); }
Example #11
Source File: JumpEffect.java From typing-label with MIT License | 6 votes |
@Override protected void onApply(TypingGlyph glyph, int localIndex, float delta) { // Calculate progress float progressModifier = (1f / intensity) * DEFAULT_INTENSITY; float normalFrequency = (1f / frequency) * DEFAULT_FREQUENCY; float progressOffset = localIndex / normalFrequency; float progress = calculateProgress(progressModifier, -progressOffset, false); // Calculate offset float interpolation = 0; float split = 0.2f; if(progress < split) { interpolation = Interpolation.pow2Out.apply(0, 1, progress / split); } else { interpolation = Interpolation.bounceOut.apply(1, 0, (progress - split) / (1f - split)); } float y = getLineHeight() * distance * interpolation * DEFAULT_DISTANCE; // Calculate fadeout float fadeout = calculateFadeout(); y *= fadeout; // Apply changes glyph.yoffset += y; }
Example #12
Source File: VanishEffectFactory.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
@Override public void draw(Batch batch) { vanishElapsed += Gdx.graphics.getDeltaTime(); // vanishElapsed might be < 0 (delay), so clamp to 0 float progress = Math.min(1f, Math.max(vanishElapsed, 0f) / vanishLifetime); // If one were to plot the elasticIn function, they would see that the slope increases // a lot towards the end- a linear interpolation between the last size + the desired // size at 20% seems to look a lot better. vanishSize = MathUtils.lerp( vanishSize, Interpolation.elasticIn.apply(cell.size, 0, progress), 0.2f ); float centerOffset = cell.size * 0.5f - vanishSize * 0.5f; Cell.draw(vanishColor, batch, cell.pos.x + centerOffset, cell.pos.y + centerOffset, vanishSize); }
Example #13
Source File: EvaporateEffectFactory.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
@Override public void draw(Batch batch) { vanishElapsed += Gdx.graphics.getDeltaTime(); // Update the size as we fade away final float progress = vanishElapsed * INV_LIFETIME; vanishSize = Interpolation.fade.apply(size, 0, progress); // Fade away depending on the time vanishColor.set(vanishColor.r, vanishColor.g, vanishColor.b, 1.0f - progress); // Ghostly fade upwards, by doing a lerp from our current position to the wavy one pos.x = MathUtils.lerp( pos.x, originalX + MathUtils.sin(randomOffset + vanishElapsed * 3f) * driftMagnitude, 0.3f ); pos.y += UP_SPEED * Gdx.graphics.getDeltaTime(); Cell.draw(vanishColor, batch, pos.x, pos.y, vanishSize); }
Example #14
Source File: EaseEffect.java From typing-label with MIT License | 6 votes |
@Override protected void onApply(TypingGlyph glyph, int localIndex, float delta) { // Calculate real intensity float realIntensity = intensity * (elastic ? 3f : 1f) * DEFAULT_INTENSITY; // Calculate progress float timePassed = timePassedByGlyphIndex.getAndIncrement(localIndex, 0, delta); float progress = MathUtils.clamp(timePassed / realIntensity, 0, 1); // Calculate offset Interpolation interpolation = elastic ? Interpolation.swingOut : Interpolation.sine; float interpolatedValue = interpolation.apply(1, 0, progress); float y = getLineHeight() * distance * interpolatedValue * DEFAULT_DISTANCE; // Apply changes glyph.yoffset += y; }
Example #15
Source File: ColorFadeTransition.java From libgdx-transitions with Apache License 2.0 | 5 votes |
/** @param color the {@link Color} to fade to * @param interpolation the {@link Interpolation} method */ public ColorFadeTransition (Color color, Interpolation interpolation) { this.color = new Color(Color.WHITE); this.interpolation = interpolation; texture = new Texture(1, 1, Format.RGBA8888); Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888); pixmap.setColor(color); pixmap.fillRectangle(0, 0, 1, 1); texture.draw(pixmap, 0, 0); }
Example #16
Source File: AlphaFadingTransition.java From libgdx-transitions with Apache License 2.0 | 5 votes |
@Override public void render (Batch batch, Texture currentScreenTexture, Texture nextScreenTexture, float alpha) { alpha = Interpolation.fade.apply(alpha); batch.begin(); batch.setColor(1, 1, 1, 1); batch.draw(currentScreenTexture, 0, 0, 0, 0, currentScreenTexture.getWidth(), currentScreenTexture.getHeight(), 1, 1, 0, 0, 0, currentScreenTexture.getWidth(), currentScreenTexture.getHeight(), false, true); batch.setColor(1, 1, 1, alpha); batch.draw(nextScreenTexture, 0, 0, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), 1, 1, 0, 0, 0, nextScreenTexture.getWidth(), nextScreenTexture.getHeight(), false, true); batch.end(); }
Example #17
Source File: PotionsWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public void handle(Ability ability) { AbilityIconCounter icon = potionIcons.get(ability); icon.image.addAction(Actions.sequence( Actions.scaleBy(0.5f, 0.5f, 0.2f, Interpolation.swingOut), Actions.scaleBy(-0.5f, -0.5f, 0.2f, Interpolation.elastic) )); setCount(ability, userData); }
Example #18
Source File: SlicingTransition.java From libgdx-transitions with Apache License 2.0 | 5 votes |
/** @param direction the {@link Direction} of the transition * @param numSlices the number of slices * @param interpolation the {@link Interpolation} method */ public SlicingTransition (Direction direction, int numSlices, Interpolation interpolation) { this.direction = direction; this.interpolation = interpolation; slices.clear(); for (int i = 0; i < numSlices; i++) slices.add(i); slices.shuffle(); }
Example #19
Source File: FadeTransition.java From Entitas-Java with MIT License | 5 votes |
@Override public void render() { float w = current.getWidth(); float h = current.getHeight(); alpha = Interpolation.fade.apply(alpha); Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.setColor(1, 1, 1, 1); batch.draw(current, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, current.getWidth(), current.getHeight(), false, true); batch.setColor(1, 1, 1, alpha); batch.draw(next, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, next.getWidth(), next.getHeight(), false, true); batch.end(); }
Example #20
Source File: ProgressBar.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
/** * Sets the interpolation to use for {@link #setAnimateDuration(float)}. */ public void setAnimateInterpolation(Interpolation animateInterpolation) { if (animateInterpolation == null) { throw new IllegalArgumentException("animateInterpolation cannot be null."); } this.animateInterpolation = animateInterpolation; }
Example #21
Source File: Actions3d.java From Scene3d with Apache License 2.0 | 5 votes |
static public ScaleToAction scaleTo (float x, float y, float z, float duration, Interpolation interpolation) { ScaleToAction action = action3d(ScaleToAction.class); action.setScale(x, y, z); action.setDuration(duration); action.setInterpolation(interpolation); return action; }
Example #22
Source File: LevelUpWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void rotateContinuously(final Image back) { back.addAction(Actions.sequence( Actions.rotateBy(-360, 6f, Interpolation.linear), Actions.run(new Runnable() { @Override public void run() { rotateContinuously(back); } }) )); }
Example #23
Source File: ClientEntityFactory.java From riiablo with Apache License 2.0 | 5 votes |
@Override public int createMissile(int missileId, Vector2 angle, Vector2 position) { int id = super.createMissile(missileId, angle, position); Missile missileWrapper = mMissile.get(id); Riiablo.assets.load(missileWrapper.missileDescriptor); Missiles.Entry missile = mMissile.get(id).missile; if (!missile.TravelSound.isEmpty()) { mSoundEmitter.create(id).set(Riiablo.audio.play(missile.TravelSound, true), Interpolation.pow2OutInverse); } return id; }
Example #24
Source File: Actions3d.java From Scene3d with Apache License 2.0 | 5 votes |
static public MoveByAction moveBy (float amountX, float amountY, float amountZ, float duration, Interpolation interpolation) { MoveByAction action = action3d(MoveByAction.class); action.setAmount(amountX, amountY, amountZ); action.setDuration(duration); action.setInterpolation(interpolation); return action; }
Example #25
Source File: SlideTransition.java From Entitas-Java with MIT License | 5 votes |
public SlideTransition(float duration, int direction, boolean slideOut, Interpolation easing, Batch batch) { super(duration, batch); this.duration = duration; this.direction = direction; this.slideOut = slideOut; this.easing = easing; }
Example #26
Source File: MenuList.java From skin-composer with MIT License | 5 votes |
public void hide() { //fade out and then remove clearActions(); AlphaAction alphaAction = new AlphaAction(); alphaAction.setAlpha(0.0f); alphaAction.setDuration(.3f); alphaAction.setInterpolation(Interpolation.fade); RemoveActorAction removeAction = new RemoveActorAction(); removeAction.setActor(this); SequenceAction sequenceAction = new SequenceAction(alphaAction, removeAction); addAction(sequenceAction); }
Example #27
Source File: MenuList.java From skin-composer with MIT License | 5 votes |
public void show(Vector2 screenPosition, Stage stage) { stage.addActor(this); setX(screenPosition.x); setY(screenPosition.y - getHeight()); //fade in clearActions(); getColor().a = 0; addAction(fadeIn(0.3f, Interpolation.fade)); selectedItem = null; selectedIndex = -1; }
Example #28
Source File: DialogImageFont.java From skin-composer with MIT License | 5 votes |
private void processSourceFile(FileHandle fileHandle, boolean setDefaults) { try { loadPixmap(fileHandle, setDefaults); preview(true); main.getProjectData().setLastFontPath(fileHandle.parent().path() + "/"); var textField = (TextField) findActor("imagepath"); textField.setText(fileHandle.path()); textField.setCursorPosition(textField.getText().length() - 1); textField = (TextField) findActor("targetpath"); textField.setText(fileHandle.parent() + "/" + fileHandle.nameWithoutExtension() + " export.fnt"); textField.setCursorPosition(textField.getText().length() - 1); ((TextButton) findActor("generate")).setDisabled(false); updateLabelHighlight(null); for (var fadable : fadables) { fadable.addAction(Actions.fadeIn(1.0f, Interpolation.fade)); fadable.setTouchable(Touchable.enabled); } ((TextButton) findActor("view characters")).setDisabled(false); } catch (InvalidFontImageException e) { Gdx.app.error(getClass().getName(), "Error processing font source image: " + fileHandle, e); main.getDialogFactory().showDialogError("Error creating font from image...", "Error creating font from image.\nPlease ensure that the image has 100% transparent pixels\nto break the different characters.\nOpen log?"); refreshTable(); } }
Example #29
Source File: HangEffect.java From typing-label with MIT License | 5 votes |
@Override protected void onApply(TypingGlyph glyph, int localIndex, float delta) { // Calculate real intensity float realIntensity = intensity * 1f * DEFAULT_INTENSITY; // Calculate progress float timePassed = timePassedByGlyphIndex.getAndIncrement(localIndex, 0, delta); float progress = MathUtils.clamp(timePassed / realIntensity, 0, 1); // Calculate offset float interpolation; float split = 0.7f; if(progress < split) { interpolation = Interpolation.pow3Out.apply(0, 1, progress / split); } else { interpolation = Interpolation.swing.apply(1, 0, (progress - split) / (1f - split)); } float distanceFactor = Interpolation.linear.apply(1.0f, 1.5f, progress); float y = getLineHeight() * distance * distanceFactor * interpolation * DEFAULT_DISTANCE; // Calculate fadeout float fadeout = calculateFadeout(); y *= fadeout; // Apply changes glyph.yoffset += y; }
Example #30
Source File: ShakeEffect.java From typing-label with MIT License | 5 votes |
@Override protected void onApply(TypingGlyph glyph, int localIndex, float delta) { // Make sure we can hold enough entries for the current index if(localIndex >= lastOffsets.size / 2) { lastOffsets.setSize(lastOffsets.size + 16); } // Get last offsets float lastX = lastOffsets.get(localIndex * 2); float lastY = lastOffsets.get(localIndex * 2 + 1); // Calculate new offsets float x = getLineHeight() * distance * MathUtils.random(-1, 1) * DEFAULT_DISTANCE; float y = getLineHeight() * distance * MathUtils.random(-1, 1) * DEFAULT_DISTANCE; // Apply intensity float normalIntensity = MathUtils.clamp(intensity * DEFAULT_INTENSITY, 0, 1); x = Interpolation.linear.apply(lastX, x, normalIntensity); y = Interpolation.linear.apply(lastY, y, normalIntensity); // Apply fadeout float fadeout = calculateFadeout(); x *= fadeout; y *= fadeout; x = Math.round(x); y = Math.round(y); // Store offsets for the next tick lastOffsets.set(localIndex * 2, x); lastOffsets.set(localIndex * 2 + 1, y); // Apply changes glyph.xoffset += x; glyph.yoffset += y; }