This project is read-only.

I can't handle MouseInput events, help!!

Nov 17, 2011 at 4:01 PM

Hello,

I'm making my first steps with Goblin XNA. I want to handle MouseInput events, but I can't. This is my Initialize function:

protected override void Initialize()
{
    base.Initialize();

    // Display the mouse cursor
    IsMouseVisible = true;

    // Initialize the GoblinXNA framework
    State.InitGoblin(graphics, Content, "");

    // Initialize the scene graph
    scene = new Scene();

    // Set the background color to CornflowerBlue color. 
    // GraphicsDevice.Clear(...) is called by Scene object with this color. 
    scene.BackgroundColor = Color.CornflowerBlue;

    // Set up the lights used in the scene
    CreateLights();

    // Set up the camera, which defines the eye location and viewing frustum
    CreateCamera();

    // Create 3D objects
    CreateObject();

    MouseInput.Instance.MouseClickEvent += new HandleMouseClick(Instance_MouseClickEvent);
}

void Instance_MouseClickEvent(int button, Point mouseLocation)
{
    Debug.WriteLine("Mouse click!!");
}

When I click with the mouse nothing happens (nothing is writen in the console), and if put a breakpoint in Instance_MouseClickEvent function the debugger doesn't stop. I don't know if I have to initialize MouseInput somehow.

Thanks for help!

Nov 17, 2011 at 7:46 PM

try Console.Out.WriteLine instead of Debug.WriteLine

Coordinator
Nov 17, 2011 at 8:05 PM

Is this 4.0? If so, are you calling scene.Update(...) in your Update(GameTime) function?

Ohan

Nov 18, 2011 at 7:32 AM
ohanoda wrote:

Is this 4.0? If so, are you calling scene.Update(...) in your Update(GameTime) function?

Ohan

Ok, I forgot to do that. Thank you!!

Coordinator
Nov 19, 2011 at 7:49 PM

4.0 has several important changes from 3.x series, so make sure to check the tutorials to see what has changed.

Ohan

Nov 21, 2011 at 7:29 AM

Es la primera vez que uso Goblin XNA, yo intentaré fijarme más de aquí en adelante.