pub struct SceneStack<C> {
pub world: C,
/* private fields */
}Expand description
A stack of Scene’s, together with a context object.
Fields§
§world: CImplementations§
Source§impl<C> SceneStack<C>
impl<C> SceneStack<C>
pub fn new(_ctx: &mut Context, global_state: C) -> Self
Sourcepub fn pop(&mut self) -> Box<dyn Scene<C>>
pub fn pop(&mut self) -> Box<dyn Scene<C>>
Remove the top scene from the stack and returns it; panics if there is none.
Sourcepub fn switch(
&mut self,
next_scene: SceneSwitch<C>,
) -> Option<Box<dyn Scene<C>>>
pub fn switch( &mut self, next_scene: SceneSwitch<C>, ) -> Option<Box<dyn Scene<C>>>
Executes the given SceneSwitch command; if it is a pop or replace
it returns Some(old_scene), otherwise None
pub fn update(&mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext)
Sourcepub fn draw(&mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext)
pub fn draw(&mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext)
Draw the current scene.
Trait Implementations§
Source§impl<C, E: Error> EventHandler<E> for SceneStack<C>
impl<C, E: Error> EventHandler<E> for SceneStack<C>
Source§fn update(
&mut self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
) -> Result<(), E>
fn update( &mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, ) -> Result<(), E>
Called upon each logic update to the game.
This should be where the game’s logic takes place.
Source§fn draw(
&mut self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
) -> Result<(), E>
fn draw( &mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, ) -> Result<(), E>
Called to do the drawing of your game.
You probably want to start this with
graphics::clear() and end it
with graphics::present().Source§fn resize_event(
&mut self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
width: f32,
height: f32,
)
fn resize_event( &mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, width: f32, height: f32, )
Called when the user resizes the window, or when it is resized
via
graphics::set_drawable_size().Source§fn mouse_motion_event(
&mut self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
x: f32,
y: f32,
dx: f32,
dy: f32,
)
fn mouse_motion_event( &mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, x: f32, y: f32, dx: f32, dy: f32, )
The mouse was moved; it provides both absolute x and y coordinates in the window,
and relative x and y coordinates compared to its last position.
Source§fn mouse_wheel_event(
&mut self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
x: f32,
y: f32,
)
fn mouse_wheel_event( &mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, x: f32, y: f32, )
The mousewheel was scrolled, vertically (y, positive away from and negative toward the user)
or horizontally (x, positive to the right and negative to the left).
A mouse button was pressed.
A mouse button was released.
Source§fn key_down_event(
&mut self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
keycode: KeyCode,
_keymods: KeyMods,
_repeat: bool,
)
fn key_down_event( &mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, keycode: KeyCode, _keymods: KeyMods, _repeat: bool, )
A keyboard button was pressed. Read more
Source§fn key_up_event(
&mut self,
ctx: &mut Context,
quad_ctx: &mut GraphicsContext,
keycode: KeyCode,
_keymods: KeyMods,
)
fn key_up_event( &mut self, ctx: &mut Context, quad_ctx: &mut GraphicsContext, keycode: KeyCode, _keymods: KeyMods, )
A keyboard button was released.
fn touch_event( &mut self, ctx: &mut Context, _quad_ctx: &mut GraphicsContext, phase: TouchPhase, _id: u64, x: f32, y: f32, )
Source§fn text_input_event(
&mut self,
_ctx: &mut Context,
_quad_ctx: &mut GraphicsContext,
_character: char,
)
fn text_input_event( &mut self, _ctx: &mut Context, _quad_ctx: &mut GraphicsContext, _character: char, )
A unicode character was received, usually from keyboard input.
This is the intended way of facilitating text input.
A gamepad button was pressed;
id identifies which gamepad.
Use input::gamepad() to get more info about
the gamepad.A gamepad button was released;
id identifies which gamepad.
Use input::gamepad() to get more info about
the gamepad.Source§fn gamepad_axis_event(
&mut self,
_ctx: &mut Context,
_quad_ctx: &mut GraphicsContext,
_axis: Axis,
_value: f32,
_id: GamepadId,
)
fn gamepad_axis_event( &mut self, _ctx: &mut Context, _quad_ctx: &mut GraphicsContext, _axis: Axis, _value: f32, _id: GamepadId, )
A gamepad axis moved;
id identifies which gamepad.
Use input::gamepad() to get more info about
the gamepad.Source§fn on_error(
&mut self,
_ctx: &mut Context,
_quad_ctx: &mut GraphicsContext,
_origin: ErrorOrigin,
_e: E,
) -> bool
fn on_error( &mut self, _ctx: &mut Context, _quad_ctx: &mut GraphicsContext, _origin: ErrorOrigin, _e: E, ) -> bool
Something went wrong, causing a
GameError.
If this returns true, the error was fatal, so the event loop ends, aborting the game.Auto Trait Implementations§
impl<C> Freeze for SceneStack<C>where
C: Freeze,
impl<C> !RefUnwindSafe for SceneStack<C>
impl<C> !Send for SceneStack<C>
impl<C> !Sync for SceneStack<C>
impl<C> Unpin for SceneStack<C>where
C: Unpin,
impl<C> !UnwindSafe for SceneStack<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more