class SFML::Scene

A chunk of game state with its own lifecycle β€” menu, gameplay, game-over, settings overlay, etc. The host SFML::App keeps a current_scene and forwards update / draw / on_event / on_resize to it. Switch between scenes with app.switch_to (or switch_to from inside a scene, which delegates).

class TitleScene < SFML::Scene on_key :enter, :start_game

def setup
  @gui = SFML::GUI::App.new(window: window, stylesheet: SHEET)
  # ... build UI ...
end

def update(dt) = @gui.update(dt)
def draw       = @gui.draw

def start_game
  switch_to PlayScene
end

end

class PlayScene < SFML::Scene # … end

class MyApp < SFML::App initial_scene TitleScene # auto-switches to it on app setup end

SFML::Scene carries its own on_key DSL β€” scene-level bindings shadow app-level bindings while the scene is active.