pub struct Atlas { /* private fields */ }Expand description
An atlas the cook made: its pages, and its sprites by name, each with
its frames on the pages and its clips. A game loads it, then its pages as
the Textures they are (Atlas::load_pages).
It needs no GPU, so Asset::finalize needs nothing in its context,
and a game can make it before its window opens, with
AssetServer::load_now. It has
no placeholder: a sprite that is not there has no region to stand in
for.
Implementations§
Source§impl Atlas
impl Atlas
Sourcepub fn page(&self, frame: &AtlasFrame) -> Option<&AtlasPage>
pub fn page(&self, frame: &AtlasFrame) -> Option<&AtlasPage>
The page of frame.
Sourcepub fn load_pages(
&self,
server: &mut AssetServer,
scope: Scope,
) -> Vec<Handle<Texture>>
pub fn load_pages( &self, server: &mut AssetServer, scope: Scope, ) -> Vec<Handle<Texture>>
Loads every page with server, in scope, as a Texture, and
returns their handles in the order of Atlas::pages, so that a
frame’s texture is handles[frame.page()]. Load the pages in the
scope the atlas was loaded in, so that unloading it frees them too.
Sourcepub fn sprites(&self) -> &[AtlasSprite]
pub fn sprites(&self) -> &[AtlasSprite]
The sprites, in byte order of their names.
Sourcepub fn sprite(&self, name: &str) -> Option<&AtlasSprite>
pub fn sprite(&self, name: &str) -> Option<&AtlasSprite>
The sprite named name: the image’s path in the source assets
without .png, such as sprites/person.
Trait Implementations§
Source§impl Asset for Atlas
impl Asset for Atlas
Source§const EXTENSIONS: &'static [&'static str]
const EXTENSIONS: &'static [&'static str]
Source§type Decoded = Atlas
type Decoded = Atlas
Asset::decode makes.Source§fn decode(bytes: &[u8], ctx: &DecodeCtx<'_>) -> Result<Atlas, AssetError>
fn decode(bytes: &[u8], ctx: &DecodeCtx<'_>) -> Result<Atlas, AssetError>
Source§fn finalize(decoded: Atlas, _: &mut FinalizeCtx<'_>) -> Result<Self, AssetError>
fn finalize(decoded: Atlas, _: &mut FinalizeCtx<'_>) -> Result<Self, AssetError>
Asset::decode made. Read moreSource§fn placeholder(ctx: &mut FinalizeCtx<'_>) -> Result<Self, AssetError>
fn placeholder(ctx: &mut FinalizeCtx<'_>) -> Result<Self, AssetError>
OnFailure::Placeholder).
None by default. Read moreSource§fn release(self, ctx: &mut FinalizeCtx<'_>) -> Result<(), AssetError>
fn release(self, ctx: &mut FinalizeCtx<'_>) -> Result<(), AssetError>
AssetServer::finish_completed_loads
calls it, with that frame’s context; a placeholder is freed the same
way. A reload’s finish calls it too, on the value, or the
placeholder, that the reload replaces, while the handle stays and
names the new value. By default the asset is only dropped. Read more