Virtual joystick control (Silverlight, Windows Phone 7/8)

Recently I created a simple "virtual" on-screen joystick control for my needs. I just wanna to share my code with developers to reduce development time :)

Download control and sample; add VirtualJoystick.xaml & VirtualJoystick.xaml.cs files to your project and enjoy. The control is too simple for the detailed description; in short, VirtualJoystick has properties:
  • public double Angle; // current angle in degrees from 0 to 360
  • public double Distance; // current distance (or "power"), from 0 to 100
  • public double AngleStep; // how often should be raised StickMove event
  • public double DistanceStep; // how often should be raised StickMove event

and events:

public event EventHandler StickCaptured // raised when user tap and hold the joystick
public event EventHandler StickMove; // raised when angle or distance exceed a threshold values set by AngleStep and DistanceStep properties.
public event EventHandler StickReleased // raised by the end of manipulations

vj1.jpg vj2.jpg

I'm not a good artist so I've tried to reproduce assets from this perfect article (with working sample) by Hemanth Sharma

If you can draw a better, more "photo-realistic" base and knob, please let me know, I'll be glad to include your work to the project. But please, the XAML drawing only (no png/jpg etc.)!


Last edited Dec 10, 2013 at 4:52 AM by SeNS, version 9