Я создаю фон, используя Inkscape, и я использую два одинаковых изображения этого фона, чтобы показать движущийся фон, но между ними появляется строка, когда я запускаю игру, любые решения?Libgdx Прокрутка Внешний вид линии
Picture for the problem in a background the line appears and disappears
Picture for the problem in another background ; the repeat of background is clear
Для уточнения более это мой фон код:
public class Background extends Actor {
private final TextureRegion textureRegion;
private Rectangle textureRegionBounds1;
private Rectangle textureRegionBounds2;
private int speed = 70;
public Background() {
textureRegion = new TextureRegion(new Texture(Gdx.files.internal(Constants.BACKGROUND_IMAGE_PATH)));
textureRegionBounds1 = new Rectangle(-800/2, 0, 800,480);
textureRegionBounds2 = new Rectangle(800/2, 0, 800, 480);
}
@Override
public void act(float delta) {
if (leftBoundsReached(delta)) {
resetBounds();
} else {
updateXBounds(-delta);
}
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
batch.draw(textureRegion, textureRegionBounds1.x, textureRegionBounds1.y, 800,480);
batch.draw(textureRegion, textureRegionBounds2.x, textureRegionBounds2.y, 800,480);
}
private boolean leftBoundsReached(float delta) {
return (textureRegionBounds2.x - (delta * speed)) <= 0;
}
private void updateXBounds(float delta) {
textureRegionBounds1.x += delta * speed;
textureRegionBounds2.x += delta * speed;
}
private void resetBounds() {
textureRegionBounds1 = textureRegionBounds2;
textureRegionBounds2 = new Rectangle(800, 0, 800, 480);
}
}
в настройках класса камеры GameStage:
...
private static final int VIEWPORT_WIDTH = 800;
private static final int VIEWPORT_HEIGHT = 480;
...
public GameStage(){
super(new ScalingViewport(Scaling.stretch, VIEWPORT_WIDTH, VIEWPORT_HEIGHT,
new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT)));
Gdx.input.setInputProcessor(this);
// renderer = new Box2DDebugRenderer();
setUpWorld();
setupCamera();
}
...
private void setupCamera() {
camera = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
camera.position.set(camera.viewportWidth/2, camera.viewportHeight/2, 0f);
camera.update();
}
...
Эти изображения в атласе текстуры, или они загружаются из отдельных файлов изображений во время выполнения? Какую текстурную фильтрацию вы используете? – Tenfour04
спасибо за ваш комментарий, я использую TextureRegion, я отредактировал свой вопрос u могу понять меня более –