2016-05-09 17 views
0

Ich versuche, meine Mausposition in C# mit open.TK zu bekommen, in meinen anderen Klassen funktioniert es gut mit Mouse.GetState(); aber in dieser Klasse ist es kaputt und fragt, ob ich eine Assembly-Referenz vermisse, obwohl ich sie benutzt habe. Irgendeine Idee, warum es nicht funktioniert?C# Open.TK Mouse.GetState() fehlt

Teil in Frage:

using System; 
using OpenTK; 
using OpenTK.Graphics.OpenGL; 
using OpenTK.Input; 

public SceneManager() 
    { 
     //Mouse.ButtonDown += Mouse_ButtonDown; 

     var mouse = Mouse.GetState(); 
     int x = mouse.X; 
     int y = mouse.Y; 
     int z = mouse.Wheel; 
    } 

Voll Klasse

using System; 
using OpenTK; 
using OpenTK.Graphics.OpenGL; 
using OpenTK.Input; 

namespace PongGame 
{ 
    class SceneManager : GameWindow 
{ 
    Scene scene; 
    static int width = 0; 
    static int height = 0; 
    int tick = 0; 
    public delegate void SceneDelegate(FrameEventArgs e); 
    public SceneDelegate renderer; 
    public SceneDelegate updater; 

    public SceneManager() 
    { 
     //Mouse.ButtonDown += Mouse_ButtonDown; 

     var mouse = Mouse.GetState(); 
     int x = mouse.X; 
     int y = mouse.Y; 
     int z = mouse.Wheel; 
    } 

    protected override void OnLoad(EventArgs e) 
    { 
     base.OnLoad(e); 

     GL.Enable(EnableCap.DepthTest); 

     base.Width = 1024; 
     base.Height = 512; 
     SceneManager.width = Width; 
     SceneManager.height = Height; 

     scene = new MainMenuScene(this); 
    } 

    protected override void OnUpdateFrame(FrameEventArgs e) 
    { 
     updater(e); 

    } 

    protected override void OnRenderFrame(FrameEventArgs e) 
    { 
     base.OnRenderFrame(e); 

     renderer(e); 


     GL.Flush(); 
     SwapBuffers(); 

    } 

    /* private void Mouse_ButtonDown(object sender, MouseButtonEventArgs e) 
    { 
     switch (e.Button) 
     { 
      case MouseButton.Left: 
       StartNewGame(); 
       break; 
      case MouseButton.Right: 
       StartMenu(); 
       break; 
     } 
    } */ 

    public void endGame(int scoreAI, int scorePlayer) 
    { 

     scene = new endGameScene(this, scoreAI, scorePlayer); 
    } 
    public void StartNewGame() 
    { 
     scene = new GameScene(this); 
    } 

    public void StartMenu() 
    { 
     scene = new MainMenuScene(this); 
    } 

    public static int WindowWidth 
    { 
     get { return width; } 
    } 

    public static int WindowHeight 
    { 
     get { return height; } 
    } 

    protected override void OnResize(EventArgs e) 
    { 
     base.OnResize(e); 

     GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height); 
     SceneManager.width = Width; 
     SceneManager.height = Height; 
    } 
} 
} 

Antwort

0

OpenTK geht davon aus GameWindow.Mouse, wenn Sie OpenTK.Input.Mouse

verwenden möchten:

var mouse = OpenTK.Input.Mouse.GetState(); 
int x = mouse.X; 
int y = mouse.Y; 
int z = mouse.Wheel;