[−][src]Struct tetra::Context
A struct containing all of the 'global' state within the framework.
Methods
impl Context
[src]
pub fn run<S, F>(&mut self, init: F) -> Result where
S: State,
F: FnOnce(&mut Context) -> Result<S>,
[src]
S: State,
F: FnOnce(&mut Context) -> Result<S>,
Runs the game.
The init
parameter takes a function or closure that creates a State
implementation. A common pattern is to use method references to pass in
your state's constructor directly - see the example below for how this
works.
Errors
If the State
returns an error from update
or draw
, the game will stop
running and this method will return the error.
Examples
use tetra::{Context, ContextBuilder, State}; struct GameState; impl GameState { fn new(ctx: &mut Context) -> tetra::Result<GameState> { Ok(GameState) } } impl State for GameState { } fn main() -> tetra::Result { // Because the signature of GameState::new is // (&mut Context) -> tetra::Result<GameState>, you can pass it // into run directly. ContextBuilder::new("Hello, world!", 1280, 720) .build()? .run(GameState::new) }
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,