當前位置: 首頁>>代碼示例>>Java>>正文


Java Interpolation.apply方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.math.Interpolation.apply方法的典型用法代碼示例。如果您正苦於以下問題:Java Interpolation.apply方法的具體用法?Java Interpolation.apply怎麽用?Java Interpolation.apply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.math.Interpolation的用法示例。


在下文中一共展示了Interpolation.apply方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convert

import com.badlogic.gdx.math.Interpolation; //導入方法依賴的package包/類
public static InterpolationStrategy convert(final Interpolation interpolation) {
    return new InterpolationStrategy() {
        @Override
        public float apply(float v1, float v2, float a) {
            return interpolation.apply(v1,v2,a);
        }
    };
}
 
開發者ID:DaanVanYperen,項目名稱:odb-dynasty,代碼行數:9,代碼來源:GdxUtil.java

示例2: interpolate

import com.badlogic.gdx.math.Interpolation; //導入方法依賴的package包/類
@Override
protected void interpolate(float elapsed, Interpolation interpolation, Vector2 start, Vector2 end) {
	float x = interpolation.apply(start.x, end.x, elapsed);
	float y = interpolation.apply(start.y, end.y, elapsed);
	camera.position.set(x, y, 0);
	redraw = true;
}
 
開發者ID:aspic,項目名稱:libgdx-maps,代碼行數:8,代碼來源:MapManager.java

示例3: tween

import com.badlogic.gdx.math.Interpolation; //導入方法依賴的package包/類
@Override
public void tween(Tint a, Tint b, float value) {

	final Interpolation linear = Interpolation.linear;

	final Color colorA = a.color;
	final Color colorB = b.color;

	color.r = linear.apply(colorA.r, colorB.r, value);
	color.g = linear.apply(colorA.g, colorB.g, value);
	color.b = linear.apply(colorA.b, colorB.b, value);
	color.a = linear.apply(colorA.a, colorB.a, value);
}
 
開發者ID:DaanVanYperen,項目名稱:artemis-odb-contrib,代碼行數:14,代碼來源:Tint.java

示例4: render

import com.badlogic.gdx.math.Interpolation; //導入方法依賴的package包/類
public void render () {
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

	float bottomLeftX = Gdx.graphics.getWidth() / 2 - graphSize / 2, bottomLeftY = Gdx.graphics.getHeight() / 2 - graphSize / 2;

	// only show up to two decimals
	String text = String.valueOf(duration);
	if (text.length() > 4) text = text.substring(0, text.lastIndexOf('.') + 3);
	text = "duration: " + text + " s (ctrl + scroll to change)";
	stage.getBatch().begin();
	list.getStyle().font.draw(stage.getBatch(), text, bottomLeftX + graphSize / 2 - list.getStyle().font.getBounds(text).width
		/ 2, bottomLeftY + graphSize + list.getStyle().font.getLineHeight());
	stage.getBatch().end();

	renderer.begin(ShapeType.Line);
	renderer.rect(bottomLeftX, bottomLeftY, graphSize, graphSize); // graph bounds
	float lastX = bottomLeftX, lastY = bottomLeftY;
	for (float step = 0; step <= steps; step++) {
		Interpolation interpolation = getInterpolation(selectedInterpolation);
		float percent = step / steps;
		float x = bottomLeftX + graphSize * percent, y = bottomLeftY + graphSize * interpolation.apply(percent);
		renderer.line(lastX, lastY, x, y);
		lastX = x;
		lastY = y;
	}
	time += Gdx.graphics.getDeltaTime();
	if (time > duration) {
		time = Float.NaN; // stop "walking"
		startPosition.set(targetPosition); // set startPosition to targetPosition for next click
	}
	// draw time marker
	renderer.line(bottomLeftX + graphSize * time / duration, bottomLeftY, bottomLeftX + graphSize * time / duration,
		bottomLeftY + graphSize);
	// draw path
	renderer.setColor(Color.GRAY);
	renderer.line(startPosition, targetPosition);
	renderer.setColor(Color.WHITE);
	renderer.end();

	// draw the position
	renderer.begin(ShapeType.Filled);
	if (!Float.isNaN(time)) // don't mess up position if time is NaN
		getPosition(time);
	renderer.circle(position.x, position.y, 7);
	renderer.end();

	stage.act();
	stage.draw();
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:50,代碼來源:InterpolationTest.java


注:本文中的com.badlogic.gdx.math.Interpolation.apply方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。