pub struct Screen {
pub asset_id: AssetId,
pub initial: bool,
pub fade_in_secs: f32,
pub toggle_key: String,
pub input: ScreenInput,
pub pauses_world: bool,
pub focus: Option<AssetId>,
pub layer: i32,
}Expand description
A named full-screen layer of UI drawn over the world: a pause menu, a settings page, a console, a score overlay.
UI elements (Sprite, TextLabel,
TextInput, HitRegion) belong to a screen by
name prefix <screen_name>_*, mirroring the Scene →
Prop convention. Active screens form a stack; each is shown /
hidden via HitRegion or KeyBinding actions:
screen:show:<name>replaces the top of the stack (menu navigation)screen:push:<name>opens on top of what is already showingscreen:hidecloses the top screen, revealing what was beneathscreen:toggle:<name>closes the screen if it is on top, opens it otherwise
Screens draw in stack order (later on top); layer orders a screen
against the always-on HUD and other screens independent of stack position.
While any active screen has pauses_world set, the world freezes exactly
as today’s pause menu does. A toggle_key opens and closes the screen from
anywhere. focus names a TextInput that receives keyboard
focus whenever the screen reaches the top of the stack. Worlds that need no
menus simply declare no screens.
Screen {
toggle_key: "Escape".into(),
..Default::default()
};Fields§
§asset_id: AssetIdAssigned by the loader; not authored.
initial: boolWhen true, this screen is shown as soon as the world loads.
fade_in_secs: f32Seconds to fade the screen in when it’s shown. 0 shows it instantly.
toggle_key: StringInputKey that toggles this screen open / closed from anywhere, by the same canonical key names a KeyBinding uses (e.g. “Escape”, “Backtick”). Empty leaves the screen action-driven only.
input: ScreenInputInput policy while the screen is active.
pauses_world: boolWhen true (the default), the world pauses beneath this screen while it is active: gameplay input, physics, and animation freeze.
focus: Option<AssetId>TextInput that receives keyboard focus whenever this screen reaches the top of the stack.
layer: i32Draw-order bias against the always-on HUD and other screens. Screens default above the HUD in stack order; a negative layer draws beneath the HUD, a higher layer stays above later-pushed screens.
Trait Implementations§
Source§impl Component for Screen
impl Component for Screen
Source§fn inject_name(&mut self, id: AssetId)
fn inject_name(&mut self, id: AssetId)
Source§fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§impl ComponentSlot for Screen
impl ComponentSlot for Screen
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.