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

The following examples show how to use com.badlogic.gdx.math.Interpolation#linear() . 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: AttractorModule.java    From talos with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: SoundManager.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
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 3
Source File: SoundManager.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
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 4
Source File: CocoStudioUIEditor.java    From cocos-ui-libgdx with Apache License 2.0 4 votes vote down vote up
/**
 * 根据传入的值返回插值类型
 */
public Interpolation getInterpolation(int tweenType) {
    switch (tweenType) {
        case 0:
            return Interpolation.linear;
        case 1:
            return Interpolation.sineIn;
        case 2:
            return Interpolation.sineOut;
        case 3:
            return Interpolation.sine;
        case 4:
            return Interpolation.linear; //不支持Quad_EaseIn
        case 5:
            return Interpolation.linear; //不支持Quad_EaseOut
        case 6:
            return Interpolation.linear; //不支持Quad_EaseInOut
        case 7:
            return Interpolation.linear; //不支持Cubic_EaseIn
        case 8:
            return Interpolation.linear; //不支持Cubic_EaseOut
        case 9:
            return Interpolation.linear; //不支持Cubic_EaseInOut
        case 10:
            return Interpolation.linear; //不支持Quart_EaseIn
        case 11:
            return Interpolation.linear; //不支持Quart_EaseOut
        case 12:
            return Interpolation.linear; //不支持Quart_EaseInOut
        case 13:
            return Interpolation.linear; //不支持Quint_EaseIn
        case 14:
            return Interpolation.linear; //不支持Quint_EaseOut
        case 15:
            return Interpolation.linear; //不支持Quint_EaseInOut
        case 16:
            return Interpolation.exp10In;
        case 17:
            return Interpolation.exp10Out;
        case 18:
            return Interpolation.exp10;
        case 19:
            return Interpolation.circleIn;
        case 20:
            return Interpolation.circleOut;
        case 21:
            return Interpolation.circle;
        case 22:
            return Interpolation.elasticIn;
        case 23:
            return Interpolation.elasticOut;
        case 24:
            return Interpolation.elastic;
        case 25:
            return Interpolation.linear; //不支持Back_EaseIn
        case 26:
            return Interpolation.linear; //不支持Back_EaseOut
        case 27:
            return Interpolation.linear; //不支持Back_EaseInOut
        case 28:
            return Interpolation.bounceIn;
        case 29:
            return Interpolation.bounceOut;
        case 30:
            return Interpolation.bounce;

        default:
            return Interpolation.linear;
    }
}
 
Example 5
Source File: SoundEmitter.java    From riiablo with Apache License 2.0 4 votes vote down vote up
@Override
protected void reset() {
  if (sound != null) sound.stop();
  sound = null;
  interpolator = Interpolation.linear;
}