Exemplo n.º 1
0
        /// <summary>
        /// Returns true if button on mouse was JUST PRESSED in current tick.
        /// <para>Note use the property name from the MouseState exactly as typed. When typed wrong, will throw a null object error</para>
        /// </summary>
        /// <param name="ButtonName">Which Mouse Button To Check</param>
        /// <returns>bool</returns>
        public bool MouseButtonIsPressed(string ButtonName)
        {
            // using vars cause these two lines are messy.
            ButtonState cmouse = (ButtonState)mouseCurrent.GetType().GetProperty(ButtonName).GetValue(mouseCurrent);
            ButtonState pmouse = (ButtonState)mousePrevious.GetType().GetProperty(ButtonName).GetValue(mousePrevious);

            return((cmouse == ButtonState.Pressed) && (pmouse == ButtonState.Released));

            /*
             * var result = ((cmouse == ButtonState.Pressed) && (pmouse == ButtonState.Released));
             * Console.WriteLine(result + " " + ButtonName + " C:"+cmouse + " - P:" + pmouse);
             * return result;
             */
        }