TextureRegionオブジェクトには、描画するときのサイズに関する情報は含まれていません。そのためには、幅、高さ、位置の変数など、描画するためのデータを含む独自のクラスを作成できます。
または、既に基本的な位置情報とサイズデータを扱っている組み込みのSpriteクラスを使用できます。デザインの観点から言えば、SpriteはTextureRegionから拡張されているため、アセットをゲームデータと組み合わせる必要はありません。ゲームオブジェクトクラスを持つことが望ましいでしょう。例:
public class GameObject {
float x, y, width, height, rotation;
TextureRegion region;
final Color color = new Color(1, 1, 1, 1);
public GameObject (TextureRegion region, float scale){
this.region = region;
width = region.getWidth() * scale;
height = region.getHeight() * scale;
}
public void setPosition (float x, float y){
this.x = x;
this.y = y;
}
public void setColor (float r, float g, float b, float a){
color.set(r, g, b, a);
}
//etc getters and setters
public void draw (SpriteBatch batch){
batch.setColor(color);
batch.draw(region, x, y, 0, 0, width, height, 1f, 1f, rotation);
}
public void update (float deltaTime) {
// for subclasses to perform behavior
}
}