FlatRedBall MouseHelper

Tagged:

This library adds some features to the FRB Mouse class:

Namespace: de.invidit.XNA
TargetFramework: .NET Framework 4
XNA Version: XNA4
Tested with FRB for XNAPC only.

The MouseHelper adds various extension methods to the Mouse class.
Just add de.invidit.XNA to your source file and you are able to use the new methods.

Vector2 GetPosition()
Returns the current 2D-position of the mouse cursor on the screen.

Vector2 GetPositionInGameWindow()
Returns the current 2D-position of the mouse cursor inside the game screen.

Vector2 GetWorldCoordinates()
Returns the world coordinates of the mouse cursor based on the sprite managers camera.

Also there is a MouseMovementCalculator included which calculated the delta of mouse movements between different calls.

Usage:
Class scope:
MouseMovementCalculator movementCalculator;
In Initialize:
movementCalculator = new MouseMovementCalculator();
In Update:
Vector2 distance = movementCalculator.GetMouseMovementDelta();
sprite.Position.X += distance.X;
sprite.Position.Y += distance.Y;

Hint:
The MouseMovementCalculator should be used with hidden mouse cursor only, since the mouse position changes permanantly.

The zip-file also includes the dependency FRBCameraHelper.dll.

Product File: 
Syndicate content