Previously, you learned about DragCallbacks and even added it to your game. But so far, you aren’t actually using it.
DragCallbacks adds four methods to your component: onDragStart, onDragUpdate, onDragEnd, and onDragCancel. You’ve already overridden one of them: onDragUpdate.
onDragUpdate is fired continuously as user drags their finger across the screen. However, it doesn’t run if the player is holding their finger still.
This is exactly the behavior you need for rotating the spaceship.
How would you rotate the ship you ask? Well, Flame’s got you covered.
All PositionComponents have a special function called lookAt. It rotates the component to look at the vector you send to it.
This way, the Spaceship will move towards the finger that is scrolling through the screen.
Demo
To rotate Spaceship. All you need to do is change onDragUpdate’s contents like so
_spaceship?.lookAt(event.canvasPosition);
This makes _spaceship turn to face the position at which the event was performed.
Build and run the game. Do drag gestures and see how the spaceship rotates around.