Events
Events flow from the Manager into the active scene, then down 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
VIDEORESIZEmay resize the camera (when fullscreen and notSCALED)- Each entity via
entity.process_event(event)(includesscene.rootand the GUI tree) 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:
# handle before entities see it
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)— entity actions, if anyhandle_event(event)— override for custom logic
GUI interactive widgets extend this with focus, hover, click, and custom handlers.
Consuming events
Set event.consumed = True (or use an Action with set_consume_event(True)) to stop further propagation.
Related hooks
Scene lifecycle (not event-based, but often used together):
do_when_added— scene linked to managerdo_update(dt)— per-frame logic after entities updatedo_on_enter/do_on_exit— stack enter/exitdo_on_enter_early/do_on_exit_early— earlier enter/exit