Events
Events flow from the Manager into the active scene, then down through layers to entities and GUI widgets. You can intercept them at several points.
Scene event order
When a scene receives an event, propagation stops as soon as event.consumed is set:
do_early_handle_event(self, event)— earliest scene hookearly_actions— scene earlyActionContainer- Player input is skipped while a transition is running
- Each scene layer via
layer.process_event(event)(entities on that layer, includingscene.rooton hud) handle_event(self, event)— main scene hookactions— sceneActionContainer
class MyScene(bf.Scene):
def do_early_handle_event(self, event):
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
event.consumed = True
def handle_event(self, event):
if event.type == pygame.KEYDOWN and event.key == pygame.K_p:
self.toggle_pause()
Entity event order
For each entity:
process_actions(event)handle_event(event)
Consuming events
Set event.consumed = True (or use an Action with set_consume_event(True)) to stop further propagation.