Java Code Examples for com.badlogic.gdx.math.MathUtils#lerp()
The following examples show how to use
com.badlogic.gdx.math.MathUtils#lerp() .
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: 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 2
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 3
Source File: FadeEffect.java From typing-label with MIT License | 6 votes |
@Override protected void onApply(TypingGlyph glyph, int localIndex, float delta) { // Calculate progress float timePassed = timePassedByGlyphIndex.getAndIncrement(localIndex, 0, delta); float progress = MathUtils.clamp(timePassed / fadeDuration, 0, 1); // Create glyph color if necessary if(glyph.color == null) { glyph.color = new Color(glyph.run.color); } // Calculate initial color if(this.color1 == null) { glyph.color.a = MathUtils.lerp(glyph.color.a, this.alpha1, 1f - progress); } else { glyph.color.lerp(this.color1, 1f - progress); } // Calculate final color if(this.color2 == null) { glyph.color.a = MathUtils.lerp(glyph.color.a, this.alpha2, progress); } else { glyph.color.lerp(this.color2, progress); } }
Example 4
Source File: SnapCounter.java From jorbs-spire-mod with MIT License | 5 votes |
public void atStartOfTurn() { currentTurn++; alpha = MathUtils.lerp(STARTING_ALPHA, ENDING_ALPHA, currentTurn / (float) SNAP_TURN); updateDescription(); boolean showingMemoryFtue = MemoryFtueTip.trigger(centerX, centerY); if (!showingMemoryFtue) { SnapFtueTip.trigger(centerX, centerY); } }
Example 5
Source File: Voiceover.java From jorbs-spire-mod with MIT License | 4 votes |
public void update() { this.duration -= Gdx.graphics.getDeltaTime(); switch (state) { case INITIAL_DELAY: if (this.duration <= 0.0F) { this.state = State.DAMPENING_MASTER_VOLUME; this.duration = Math.max(dampeningDuration, 0.01F); } break; case DAMPENING_MASTER_VOLUME: float dampenProgress = dampeningDuration <= 0.0F ? 1.0F : MathUtils.clamp(1 - duration / dampeningDuration, 0F, 1F); VoiceoverMaster.MASTER_DAMPENING_FACTOR = MathUtils.lerp(1.0F, DAMPENING_FACTOR, dampenProgress); CardCrawlGame.music.updateVolume(); if (this.duration <= 0.0F) { if (VoiceoverMaster.VOICEOVER_SUBTITLES_ENABLED) { AbstractDungeon.effectList.add(new SpeechBubble(source.dialogX, source.dialogY, PLAY_DURATION, subtitle, source.isPlayer)); } sfx.play(Settings.MASTER_VOLUME * VoiceoverMaster.VOICEOVER_VOLUME * VoiceoverMaster.VOICEOVER_VOLUME_MODIFIER); this.state = State.PLAYING_SFX; this.duration = PLAY_DURATION; } break; case PLAYING_SFX: if (this.duration <= 0.0F) { this.state = State.RESTORING_MASTER_VOLUME; this.duration = DAMPENING_RESTORE_DURATION; } break; case RESTORING_MASTER_VOLUME: float restoreProgress = MathUtils.clamp(1 - duration / DAMPENING_RESTORE_DURATION, 0F, 1F); VoiceoverMaster.MASTER_DAMPENING_FACTOR = MathUtils.lerp(DAMPENING_FACTOR, 1.0F, restoreProgress); CardCrawlGame.music.updateVolume(); if (this.duration <= 0.0F) { VoiceoverMaster.MASTER_DAMPENING_FACTOR = 1.0F; this.state = State.DONE; } break; } }
Example 6
Source File: SnapCounter.java From jorbs-spire-mod with MIT License | 4 votes |
public void forceSnapTurn() { currentTurn = SNAP_TURN; alpha = MathUtils.lerp(STARTING_ALPHA, ENDING_ALPHA, currentTurn / 7.0F); tips.get(0).body = String.format(TEXT[2]); }
Example 7
Source File: WeightVector.java From gdx-gltf with Apache License 2.0 | 4 votes |
public void lerp(WeightVector value, float t) { if(count != value.count) throw new GdxRuntimeException("WeightVector count mismatch"); for(int i=0 ; i<count ; i++){ values[i] = MathUtils.lerp(values[i], value.values[i], t); } }