0

I would like to create a joystick (x,y) control based on C# WPF - Virtual joystick using polar coordinates.

How can I animate (like a spring) the knob returning to its central position after the mouse button is released?

Issung
  • 385
  • 3
  • 14
Boris Makovecki
  • 63
  • 1
  • 2
  • 4
  • What I would do is check if the mouse button is released, if it is, subtract a small amount from the x and y positions until they go back to 0. Or you could ease it by doing something like this: `x *= 0.8f;` – Issung Oct 28 '19 at 01:55
  • In `WPF` use animations with easing functions [MSDN](https://learn.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/easing-functions) – XAMlMAX Oct 28 '19 at 09:45
  • I have tried easing functions, and they return knob to center, but when FillBehavior="HoldEnd", knob can't move after animation. If i set FillBehavior="Stop" knob returns to dragged position after animation is done…. – Boris Makovecki Oct 28 '19 at 18:11

0 Answers0