回転するスプライトがあり、タッチ入力を離すとすぐに 0 度に戻ります。タッチ入力がリリースされる直前にスプライトの回転 (度数など) を取得するにはどうすればよいですか?
私は調べましたが、グーグルにとって難しい質問を達成する方法が見つかりません。
編集潜在的な応答で申し訳ありません。これまでのコードは次のとおりです。rPower 変数を使用して発射体を誘導できますか? まだそこまで行っていません。
@Override
public boolean touchDown(int x, int y, int pointer, int button) {
if (Gdx.input.isTouched(0)) {
cam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
}
if (Gdx.input.isTouched(1)) {
cam.unproject(touchPoint2.set(Gdx.input.getX(), Gdx.input.getY(), 0));
}
return true;
}
@Override
public boolean touchDragged(int x, int y, int pointer) {
if (Gdx.input.isTouched(0)) {
cam.unproject(dragPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
dx = touchPoint.x - dragPoint.x;
dy = touchPoint.y - dragPoint.y;
throwerLowerArmSprite.setRotation(dx * 30);
}
if (Gdx.input.isTouched(1)){
cam.unproject(dragPoint2.set(Gdx.input.getX(), Gdx.input.getY(), 0));
d1x = dragPoint2.x - touchPoint2.x;
d1y = dragPoint2.y - touchPoint2.y;
throwerUpperArmSprite.setRotation(d1x * 30);
}
return true;
}
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
if (!Gdx.input.isTouched(0)) {
cam.unproject(releasePoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
rPower = releasePoint.x - touchPoint.x;
throwerLowerArmSprite.setRotation(0);
}
if (!Gdx.input.isTouched(1)) {
cam.unproject(releasePoint2.set(Gdx.input.getX(), Gdx.input.getY(), 0));
rPower = releasePoint2.x - touchPoint2.x;
throwerUpperArmSprite.setRotation(0);
}
return true;
}