Windows Phone 8 Joystick User Control Project on GitHub

I recently needed a user control for Windows Phone 8 that behaves like a Joystick. I spent a few hours tweaking the code so I thought it might be worth sharing.

The link to the GitHub repo is: https://github.com/TechPreacher/WP8-Joystick-UserControl.git 

SNAGHTML38c21426

WP8-Joystick is a user control for Windows Phone 8 XAML/C# projects that displays an on-screen Joystick.

When the blue handle is dragged/moved on top of the main circle, the control uses a timer that fires an event “NewCoordinates” in a definable interval, set in the “TimerMilliSeconds” property. Setting “TimerMilliSeconds” to 1000 for example will cause the “NewCoordinates” event to fire every second as long as the joystick is manipulated (and the handle is actually moved). When the Joystick is released, the handle returns to the center and it fires a “Stop” event to notify the application.

The “NewCoordinates” event returns an object of type WP8_Joystick.Joystick.MyCoordinates which contains two integers: Direction and Speed. Direction is the angle in which the handle is moved from the center of the control in a 360 degree scale with the top of the control being 0. Speed is the distance between the handle and the center ranging between 0 and 255.

image

The Joystick monitors touch frames which can be enabled and disabled by the “StartJoystick” and “StopJoystick” methods.

Tags:

About TechPreacher

Developer evangelist for Microsoft in Switzerland. Focus on web 2.0 technologies, Windows 8 and Windows Phone development. Passionate gamer with a life.

3 responses to “Windows Phone 8 Joystick User Control Project on GitHub”

  1. cordialguyhussain says :

    can you help me build a joystick form which i can controll games

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: