[−][src]Struct ggez::Context
A Context
is an object that holds on to global resources.
It basically tracks hardware state such as the screen, audio
system, timers, and so on. Generally this type can not
be shared/sent between threads and only one Context
can exist at a time. Trying
to create a second one will fail. It is fine to drop a Context
and create a new one, but this will also close and re-open your
game's window.
Most functions that interact with the hardware, for instance
drawing things, playing sounds, or loading resources (which then
need to be transformed into a format the hardware likes) will need
to access the Context
. It is an error to create some type that
relies upon a Context
, such as Image
, and then drop the Context
and try to draw the old Image
with the new Context
. Most types
include checks to make this panic in debug mode, but it's not perfect.
All fields in this struct are basically undocumented features,
only here to make it easier to debug, or to let advanced users
hook into the guts of ggez and make it do things it normally
can't. Most users shouldn't need to touch these things directly,
since implementation details may change without warning. The
public and stable API is ggez
's module-level functions and
types.
Fields
filesystem: Filesystem
Filesystem state
timer_context: TimeContext
Timer state
audio_context: Box<dyn AudioContext>
Audio context
keyboard_context: KeyboardContext
Keyboard context
mouse_context: MouseContext
Mouse context
gamepad_context: Box<dyn GamepadContext>
Gamepad context
continuing: bool
Controls whether or not the event loop should be running.
Set this with ggez::event::quit()
.
Methods
impl Context
[src]
pub fn process_event(&mut self, event: &Event)
[src]
Feeds an Event
into the Context
so it can update any internal
state it needs to, such as detecting window resizes. If you are
rolling your own event loop, you should call this on the events
you receive before processing them yourself.
Trait Implementations
Auto Trait Implementations
impl Unpin for Context
impl !Sync for Context
impl !Send for Context
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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<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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T> Erased for 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>,
Sets value
as a parameter of self
.