画面の中心からタッチ座標(時計の針)までテクスチャを描画しようとしています。これを説明するShapeRenderer
ために、中心から接触点までの線を作成する を作成しました。コードの下
if (Gdx.input.isTouched()) {
camera.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
debugRenderer.begin(ShapeType.Line);
debugRenderer.setColor(Color.ORANGE);
debugRenderer.line(centerObject.x, centerObject.y, touchPoint.x, touchPoint.y);
debugRenderer.end()
}
これはうまくいきます。次に、線を実際の画像に置き換える必要があります(タッチ位置に基づいてスケーリングする必要があります)。中心点からテクスチャを描いてみました。
public void draw (TextureRegion region, float x, float y, float originX, float originY, float width, float height,
float scaleX, float scaleY, float rotation)
SpriteBatch
テクスチャを描くのに役立ちます。しかし、それは機能していません。コードの下
private TextureRegion handRegion;
private Texture handTexture;
handTexture = new Texture(
Gdx.files.internal("hand.png"));
handRegion = new TextureRegion(handTexture);
//origin_X,origin_Y are the center of the screen
if (Gdx.input.isTouched()) {
camera.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
game.batch.begin();
game.batch.draw(handRegion, touchPoint.x, touchPoint.y, origin_X, origin_Y,10,100,1,1,0);
game.batch.end();
}
これを解決する助けに本当に感謝しています。