Пример #1
0
        /// <summary>
        /// 响应键盘释放事件
        /// Invoke (https://msdn.microsoft.com/zh-cn/library/zyzhdc6b.aspx)
        /// </summary>
        /// <param name="args"></param>
        private void OnKeyUp(XKeyboardEventArgs args)
        {
            XKeyboardHandler <XKeyboardEventArgs> temp = m_keyUp;

            if (temp != null)
            {
                temp.Invoke(args);
            }
        }
Пример #2
0
        protected override void GameKeyDown(XKeyboardEventArgs args)
        {
            if (!m_bkeydown)
            {
                Console.WriteLine("按下键:" + args.GetKey());
                m_bkeydown = true;
            }

            if (args.GetKey() == XKeys.Escape)
            {
                SetGameOver(true);
            }
        }
Пример #3
0
        public void KeyboardEventsHandler()
        {
            XKeyboardEventArgs e;
            XKeys xKeyDown = GetCurDownKey();

            if (xKeyDown != XKeys.None)
            {
                // 有新的按键被按下
                this.m_oldKey = xKeyDown;
                e             = new XKeyboardEventArgs(xKeyDown);
                this.OnKeyDown(e);
            }
            else if (this.m_oldKey != XKeys.None && !isKeyDown(this.m_oldKey))
            {
                // 有旧的按键被释放
                e = new XKeyboardEventArgs(this.m_oldKey);
                this.OnKeyUp(e);
                this.m_oldKey = XKeys.None;
            }
        }
Пример #4
0
 protected override void GameKeyUp(XKeyboardEventArgs args)
 {
     Console.WriteLine("释放键:" + args.GetKey());
     m_bkeydown = false;
 }
Пример #5
0
 /// 键盘释放虚拟函数
 protected virtual void GameKeyUp(XKeyboardEventArgs e)
 {
     // 此处处理键盘释放事件
 }
Пример #6
0
 /// 键盘按下虚拟函数
 protected virtual void GameKeyDown(XKeyboardEventArgs e)
 {
     // 此处处理键盘按下事件
 }