私は libdgx 開発とゲーム開発の初心者です。Andreas Oehlke の本「Learning Libgdx Game Development」を読んでいて、並行して自分のゲームを開発しようとしています。背景を追加しようとすると問題が発生します。本では色を使っているのでとてもシンプルです。しかし、テクスチャアトラスから画像を追加したいです。画面全体を復元するには画像が小さすぎるので、繰り返したいと思います。regBackground はテクスチャではないため、regBackground.setWrap(TextureWrap.Repeat, TextureWrap.Repeat) を使用できません。どうすれば問題を適切に解決できますか?
public class Background extends AbstractGameObject {
private TextureRegion regBackground;
public Background () {
init();
}
private void init () {
dimension.set(1f, 1f);
regBackground = Assets.instance.levelDecoration.background;
}
public void render (SpriteBatch batch) {
TextureRegion reg = null;
reg = regBackground;
batch.draw(reg.getTexture(),
position.x, position.y,
origin.x, origin.y,
dimension.x, dimension.y,
scale.x, scale.y,
rotation,
reg.getRegionX(), reg.getRegionY(),
reg.getRegionWidth(), reg.getRegionHeight(),
false, false);
}
}
私の Assets クラスには、テクスチャ アトラス内の領域を見つけるための次のコードがあります。
public class AssetLevelDecoration {
public final AtlasRegion background;
public AssetLevelDecoration (TextureAtlas atlas) {
background = atlas.findRegion("background");
}
}