[][src]Struct gate::AppContext

pub struct AppContext<A: AppAssetId> {
    pub audio: Audio<A>,
    // some fields omitted
}

Context passed to methods in App.

Fields

audio: Audio<A>

Audio playback.

Methods

impl<A: AppAssetId> AppContext<A>[src]

pub fn dims(&self) -> (f64, f64)[src]

Returns the app (width, height), which are restricted by the min/max dimensions specified in AppInfo.

pub fn cursor(&self) -> (f64, f64)[src]

Returns the mouse cursor (x, y) position in app coordinates.

The x coordinate lies in the range 0 to self.dims().0. The y coordinate lies in the range 0 to self.dims().1.

pub fn native_px(&self) -> f64[src]

Returns the width of a native pixel, measured in "app pixels".

This value will always be at most 1.

pub fn native_px_align(&self, x: f64, y: f64) -> (f64, f64)[src]

Convenience method for aligning an (x, y) position to the nearest native pixel boundaries.

This is typically used to align a camera position. See also self.native_px().

pub fn request_fullscreen(&mut self)[src]

Requests the app to enter fullscreen mode.

Depending on the target and how this method is invoked, the app may or may not actually enter fullscreen mode. When compiling to wasm32-unknown-unknown and running in a web browser, fullscreen requests can only be made successfully during certain user input events, so invoking fullscreen during App.start or App.advance will likely fail.

pub fn cancel_fullscreen(&mut self)[src]

Requests the app to cancel fullscreen mode.

pub fn is_fullscreen(&self) -> bool[src]

Checks whether or not the app is currently in fullscreen mode.

This value will not change immediately after a call to request_fullscreen or cancel_fullscreen.

pub fn close(&mut self)[src]

Closes the app entirely.

When compiling to wasm32-unknown-unknown, the app may be resumed after it is closed via invoking a JavaScript method.

pub fn cookie(&self) -> &[u8][src]

Gets current cookie data.

NOTE: this API is likely to change change. Returns an empty array if cookie is not set or if not running in WebAssembly mode.

Writes cookie data.

NOTE: this API is likely to change change. Cookie can be used as lightweight save data when built in WebAssembly mode. Only writes persistent cookie data if built in WebAssembly mode. To use cookies, the readCookie and writeCookie functions must be passed into gate.js.

Auto Trait Implementations

impl<A> RefUnwindSafe for AppContext<A> where
    A: RefUnwindSafe

impl<A> !Send for AppContext<A>

impl<A> !Sync for AppContext<A>

impl<A> Unpin for AppContext<A> where
    A: Unpin

impl<A> UnwindSafe for AppContext<A> where
    A: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.