Presentation is loading. Please wait.

Presentation is loading. Please wait.

Game User Input Mouse Input.

Similar presentations


Presentation on theme: "Game User Input Mouse Input."— Presentation transcript:

1 Game User Input Mouse Input

2 Introduction Much like Keyboard Input, Mouse Input also serves as both a data entry and controller unit With a Mouse we are limited to detecting clicks and its location. However, this is all a mouse is truly designed for anyway.

3 Mouse Location We can retrieve the position of the Mouse at any point using the Input.GetMousePos() command. However, you must realize it returns a new data type called a Vector2F. This is simply an xy coordinate where each value is a float. Yes, it gives back both values in one variable. So when you wish to store the mouse’s location, you can either create two separate variables for each value, or you too can create a Vector2F variable: Vector2F mousePos = new Vector2F(0f,0f); //Set it to location 0,0 to start To retrieve the mouse coordinate then: mousePos.x = Input.GetMousePos().x; mousePos.y = Input.GetMousePos().y; As a side note, it is best to do this inside the check for a button click, as it can be an expensive task if done 60 times per second no matter what…

4 Mouse Click This is done in the same way as checking for a keyboard key 60 times per second, we use an if-statement: if (Input.IsMouseButtonReleased(Input.MOUSE_LEFT)) { //Check to see if the mouse clicked on something important } You can check for any of the three buttons: Input.MOUSE_LEFT Input.MOUSE_MID Input.MOUSE_RIGHT


Download ppt "Game User Input Mouse Input."

Similar presentations


Ads by Google