Struct gate::AppContext

source ·
pub struct AppContext<A: AppAssetId> {
    pub audio: Audio<A>,
    /* private fields */
}
Expand description

Context passed to methods in App.

Fields

audio: Audio<A>

Audio playback.

Implementations

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

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.

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

This value will always be at most 1.

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().

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.

Requests the app to cancel fullscreen mode.

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.

Closes the app entirely.

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

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

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.