ImageAsset
assets/image-asset.ts:29 Extends Asset
An Asset wrapping a loaded raster image as a GPU texture.
ImageAsset is what AssetLibrary.load produces for any path that
resolves to AssetType.Image — PNG, JPEG, WebP, GIF, AVIF, BMP, or
SVG. It is the handoff between the asset layer and the rendering layer:
texture- and sprite-rendering components take an ImageAsset and pull the
underlying texture from it internally, so game code references images by
key and never touches a texture object itself.
The PIXI Texture is deliberately not part of arcade2d's stable surface
— it is reachable only through ImageAsset.raw, the escape hatch.
The dimensions a layout-minded caller actually needs are surfaced as plain
numbers via ImageAsset.width and ImageAsset.height.
Example
await game.assets.load('sprites/player.png', { key: 'player' });
const player = game.assets.get('player') as ImageAsset;
console.log(player.width, player.height);Constructors
constructor(key: string, namespace: string, src: string, _texture: Texture): ImageAsset Parameters
-
keystring -
namespacestring -
srcstring -
_textureTexture
Properties
key: string The developer-facing name this asset is stored under within its Asset.namespace. Unique per namespace, not globally.
namespace: string The grouping this asset belongs to. The unit of bulk unloading via AssetLibrary.unloadNamespace.
src: string The resolved path the resource was loaded from. Also the underlying renderer's cache key, used to free the resource on unload.
Accessors
raw: Texture Direct access to the underlying PIXI Texture instance.
Use with care. raw is an intentional escape hatch for cases the
arcade2d API doesn't cover — feeding the texture into a custom shader or
filter, building a TilingSprite, slicing sub-textures by frame,
anything we haven't decided how to model yet. Code that touches raw is
coupled to PIXI's public API and may break when:
- arcade2d upgrades PIXI (including minor versions).
- PIXI itself ships a breaking change.
- arcade2d swaps PIXI for a different renderer.
None of those will be treated as breaking changes to arcade2d's own
surface. Prefer the typed accessors on this class; reach for raw only
when no equivalent exists, and isolate the access behind your own helper
so the coupling is in one place.