本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.lerp方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.lerp方法的具体用法?Java MathUtils.lerp怎么用?Java MathUtils.lerp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.MathUtils
的用法示例。
在下文中一共展示了MathUtils.lerp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
@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);
}
示例2: draw
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
@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);
}