Struct amethyst::Application
[−]
[src]
pub struct Application<'a, 'b> { pub world: World, // some fields omitted }
An Application is the root object of the game engine. It binds the OS event loop, state machines, timers and other core components in a central place.
Since Application functions as the root of the game, Amethyst does not need to use any global variables. Within this object is everything that your game needs to run.
Fields
world: World
The world
Methods
impl<'a, 'b> Application<'a, 'b>
[src]
fn new<P, S>(path: P, initial_state: S) -> Result<Application<'a, 'b>> where
P: AsRef<Path>,
S: State + 'a,
[src]
P: AsRef<Path>,
S: State + 'a,
Creates a new Application with the given initial game state. This will create and allocate all the needed resources for the event loop of the game engine. It is a shortcut for convenience if you need more control over how the engine is configured you should be using build instead.
Parameters
path
: The default path for asset loading.initial_state
: The initial State handler of your game See State for more information on what this is.
Returns
Returns a Result
type wrapping the Application
type. See
errors for a full list of
possible errors that can happen in the creation of a Application object.
Type Parameters
P
: The path type for your standard asset path.S
: A type that implements theState
trait. e.g. Your initial game logic.
Lifetimes
a
: The lifetime of theState
objects.b
: This lifetime is inherited fromspecs
andshred
, it is the minimum lifetime of the systems used byApplication
Errors
Application will return an error if the internal thread pool fails to initialize correctly because of systems resource limitations
Examples
use amethyst::prelude::*; struct NullState; impl State for NullState {} let mut game = Application::new("assets/", NullState).expect("Failed to initialize"); game.run();
fn build<P, S>(
path: P,
initial_state: S
) -> Result<ApplicationBuilder<'a, 'b, S>> where
P: AsRef<Path>,
S: State + 'a,
[src]
path: P,
initial_state: S
) -> Result<ApplicationBuilder<'a, 'b, S>> where
P: AsRef<Path>,
S: State + 'a,
Creates a new ApplicationBuilder with the given initial game state.
This is identical in function to ApplicationBuilder::new.