Ejemplo n.º 1
0
        // This method handles the state updates that can be caused by key press
        // events. Key events may mean different things depending on what has
        // come before, to support this concept this method takes an opaque
        // context object as a parameter and returns an updated version. This
        // context should be set to null for the first event then should be set
        // to the last value returned for subsequent events.
        protected object ProcessKeyEvent(KeyGameEvent ev, object context)
        {
            if (ev.Up)
            {
                // If it is a key up on the fire key
                // make sure we mute the associated sound
                if (ev.KeyCode == Keycode.DpadCenter)
                {
                    return(null);
                }
            }
            else
            {
                // If it is a key down on the fire key start playing the sound and
                // update the context to indicate that a key has been
                // pressed and to ignore further presses
                if (ev.KeyCode == Keycode.DpadCenter && (context == null))
                {
                    return(ev);
                }
            }

            // Return the context unchanged
            return(context);
        }
Ejemplo n.º 2
0
        // This method handles the state updates that can be caused by key press
        // events. Key events may mean different things depending on what has
        // come before, to support this concept this method takes an opaque
        // context object as a parameter and returns an updated version. This
        // context should be set to null for the first event then should be set
        // to the last value returned for subsequent events.
        protected object ProcessKeyEvent(KeyGameEvent ev, object context)
        {
            if (ev.Up) {
                // If it is a key up on the fire key
                // make sure we mute the associated sound
                if (ev.KeyCode == Keycode.DpadCenter)
                    return null;
            } else {
                // If it is a key down on the fire key start playing the sound and
                // update the context to indicate that a key has been
                // pressed and to ignore further presses
                if (ev.KeyCode == Keycode.DpadCenter && (context == null))
                    return ev;
            }

            // Return the context unchanged
            return context;
        }