예제 #1
0
        /// <summary>Fixed the update.</summary>
        public override void FixedUpdate()
        {
            for (int i = 0; i < KeyboardsValues.Length; i++)
            {
                TempKey = Enum.Parse <SFML.Window.Keyboard.Key>(KeyboardsNames[i]);
                if (SFML.Window.Keyboard.IsKeyPressed(TempKey))
                {
                    if (!Keys.Contains(KeyboardsValues[i]))
                    {
                        Keys.Add(KeyboardsValues[i]);
                        PressDown(KeyboardsValues[i]);
                        OnPressDownKey.Invoke(this, KeyboardsValues[i]);
                    }

                    PressKey(KeyboardsValues[i]);
                    OnPressKey.Invoke(this, KeyboardsValues[i]);
                }
                else
                {
                    if (Keys.Contains(KeyboardsValues[i]))
                    {
                        Keys.Remove(KeyboardsValues[i]);
                        PressUp(KeyboardsValues[i]);
                        OnReleaseKey.Invoke(this, KeyboardsValues[i]);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>Polls the events.</summary>
        internal static void PollEvents()
        {
            foreach (SFML.Window.Keyboard.Key key in Enum.GetValues(typeof(SFML.Window.Keyboard.Key)))
            {
                if (SFML.Window.Keyboard.IsKeyPressed(key))
                {
                    if (!keys.Contains(key))
                    {
                        keys.Add(key);
                        if (OnPressKeyOnce != null)
                        {
                            OnPressKeyOnce.Invoke(null, key);
                        }
                    }
                }

                if (SFML.Window.Keyboard.IsKeyPressed(key))
                {
                    if (OnPressKey != null)
                    {
                        OnPressKey.Invoke(null, key);
                    }
                }

                if (!SFML.Window.Keyboard.IsKeyPressed(key) && keys.Contains(key))
                {
                    keys.Remove(key);
                }
            }
        }