Java Code Examples for com.badlogic.gdx.math.Interpolation#swingOut()

The following examples show how to use com.badlogic.gdx.math.Interpolation#swingOut() . 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: EaseEffect.java    From typing-label with MIT License 6 votes vote down vote up
@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 2
Source File: SlideEffect.java    From typing-label with MIT License 6 votes vote down vote up
@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 x = getLineHeight() * distance * interpolatedValue * DEFAULT_DISTANCE;

    // Apply changes
    glyph.xoffset += x;
}