-
Notifications
You must be signed in to change notification settings - Fork 552
Adding a mouse to our Non Flickering Canvas GUI
samnad edited this page Oct 2, 2020
·
1 revision
Welcome! I'm assuming that you're coming from my previous tutorial. If you haven't, this is based on that, so go look at it.
First, we have to initialize the mouse manager so we know where the mouse is. Add this to your init method.
Cosmos.System.MouseManager.ScreenWidth = Convert.ToUInt32(screenX);
Cosmos.System.MouseManager.ScreenHeight = Convert.ToUInt32(screenY);
This lets the Cosmos MouseManager know the screen dimensions and start tracking the mouse. Now, all we need to do is add a setPixel call to the update() method and we're done! So, add this to the update method:
setPixel(Convert.ToInt32(Cosmos.System.MouseManager.X), Convert.ToInt32(Cosmos.System.MouseManager.Y), Color.White);
That's it! With the framework that we have built here, it is easy to add new methods and features. Good luck, and if you have any issues, feel free to contact me!