Saturday, June 23, 2012

Kinect SkeletonFrame

SkeletonFrame is a sealed (cannot be inherited) class in Microsoft.Kinect namespace. SkeletonFrame class contains skeleton frame returned by the Kinect API. 

Friday, June 22, 2012

When to use Static Classes in C#

Static classes and static class members are used to create functions which can be accessed without creating an instance of it. Static class members can be used to separate data and behavior that is independent. 


Some of the features of the static classes are, 

  • Only contains static members
  • Cannot be instantiated 
  • They are sealed
Static classes cannot be created using new keyword. Static classes are loaded by the .NET CLR when the program containing the class is loaded. 


Monday, June 18, 2012

Track MouseWheel in XNA

Photo courtesy : ehow.com 
Sometimes in your XNA Application you might need to track the mousewheel event to do some task. Luckily XNA has inbuilt function for this. MouseState class has a property called ScrollWheelValue which returns the current MouseWheel value. 


As the documentation specifies,
ScrollWheelValue : Gets the cumulative mouse scroll wheel value since the game was started.


Unlike Winforms, in XNA ScrollWheelValue reports the total scroll wheel value. To get the wheel movement you must track and compare with the previous ScrollWheelValue. 


MouseState mouseState = Mouse.GetState();

float ScrollWheelChange =mouseState.ScrollWheelValue;