Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

MouseState not changing in Custom game loop (no Game class)

$
0
0

@ToolmakerSteve wrote:

On Windows, using MonoGame.Framework.WindowsDX 3.7.0.944.
(Windows 10, but not "UWP" app; Surface Pro (2017))

If use MonoGame template, the following code in Game.Update override sees changed MouseState each loop.
C#:

        MouseState mouseState = Mouse.GetState();
        if (mouseState.X != 0)
        {
            int i = 1;   // Breakpoint here.
        }
        if (mouseState.RightButton == ButtonState.Pressed)
        {
            int i = 1;   // Breakpoint here.
        }

Putting the same code into a desktop application that uses custom code to do the looping (no Game class), the MouseState never changes from default (0,0), no buttons pressed.

VB (breakpoints never hit):

    Dim mouseState As MouseState = Mouse.GetState
    If mouseState.X <> 0 Then
        Test()
    End If
    If mouseState.RightButton = ButtonState.Pressed Then
        Test()
    End If

NOTE: FrameworkDispatcher.Update() is called per loop; adding to the code used in this topic.

Q: What do I need to do to initialize the Mouse class?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles