[Bf-committers] Patch for BGE Keyboard and Mouse Python types
Mitchell Stokes
mogurijin at gmail.com
Wed Apr 14 09:01:48 CEST 2010
> +1 for Dalai's suggestions, though I'd like to make sure we take care
> when adding another method to access events.
> Assume 'events' includes events since the last logic tick? (as opposed
> to accumulating events and having the developer remove?)
I'm close to have the suggestions implemented and I'll be submitting a
new patch probably tomorrow. As for the events, they being done just
like SCA_KeyboardSensor.events. It returns a list events and statuses
for inputs that are active for that frame.
Here is the example from the GameKeys doc:
# Do the all keys thing
import GameLogic
import GameKeys
co = GameLogic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.getSensor('Keyboard')
keylist = sensor.events
for key in keylist:
# key[0] == GameKeys.keycode, key[1] = status
if key[1] == GameLogic.KX_INPUT_JUST_ACTIVATED:
if key[0] == GameKeys.WKEY:
# Activate Forward!
if key[0] == GameKeys.SKEY:
# Activate Backward!
if key[0] == GameKeys.AKEY:
# Activate Left!
if key[0] == GameKeys.DKEY:
# Activate Right!
Cheers,
Mitchell Stokes (Moguri)
More information about the Bf-committers
mailing list