vanilladocs
vanillapunch.com
API / core/asset

core/asset

애셋.

Asset.

Assetextends Object

짝Counterpart: vanilla-engine Asset

애셋.

Asset.

예제Example이미지 애셋을 읽고 상태 보기Load an image asset and check its state
import { ImageAsset } from "./build/vanilla.js";

const imageAsset = new ImageAsset();
await imageAsset.load("examples/assets/spritesheet.png");
console.log(imageAsset.getAssetType(), imageAsset.getAssetPath(), imageAsset.isLoaded());
imageAsset.unload();
console.log(imageAsset.isLoaded(), imageAsset.getAssetPath());
생성자constructorconstructor()#0.0.8 부터since 0.0.8소스source

생성.

Constructor.

짝Counterpart: vanilla-engine AssetBase.new

메서드methodasync load(assetPath)#0.0.8 부터since 0.0.8소스source

비동기 애셋 로드.

Loads the asset asynchronously.

assetPathstring
애셋 경로. (이미 로드되었으면 아무것도 하지 않는다)Asset path. (does nothing if already loaded)

반환ReturnsPromise<void> 경로를 정하면 풀리는 프로미스. (이 기반 함수는 읽지 않고 로드 상태도 바꾸지 않는다)A promise resolved once the path is set. (this base function does not read anything or change the loaded state)

메서드methodunload()#0.0.8 부터since 0.0.8소스source

애셋 언로드.

  • 그 자리에서 끝나고 아무것도 돌려주지 않는다. (로드되어 있었든 아니든 같다, 덮어쓴 하위 클래스와 같다)

Unloads the asset.

  • Finishes immediately and returns nothing. (the same whether it was loaded or not, same as the overriding subclasses)

짝Counterpart: vanilla-engine AssetBase.unload

메서드methodsetAssetType(assetType)#0.0.10 부터since 0.0.10소스source

애셋 타입 설정.

Sets the asset type.

assetTypestring
애셋 타입 이름. ("image", "audio", "json", "text", "font", "blob" 같은, 하위 클래스가 생성자에서 정한다)Asset type name. (such as "image", "audio", "json", "text", "font", "blob", set by subclasses in their constructor)
메서드methodgetAssetType()#0.0.10 부터since 0.0.10소스source

애셋 타입 반환.

Returns the asset type.

반환Returnsstring 애셋 타입 이름. (정하지 않았으면 "none")Asset type name. ("none" if not set)

짝Counterpart: vanilla-engine AssetBase.get_asset_type

메서드methodsetAssetPath(assetPath)#0.0.9 부터since 0.0.9소스source

로드 경로 설정.

Sets the load path.

assetPathstring
로드 경로.Load path.
메서드methodgetAssetPath()#0.0.9 부터since 0.0.9소스source

로드 경로 반환.

Returns the load path.

반환Returnsstring 로드 경로. (로드 전이나 언로드 뒤에는 빈 글)Load path. (empty string before loading or after unloading)

짝Counterpart: vanilla-engine AssetBase.get_asset_path

메서드methodsetLoaded(isLoaded)#0.0.9 부터since 0.0.9소스source

로드 되었는지 여부 설정.

Sets whether it is loaded.

isLoadedboolean
로드 되었으면 참.True if loaded.
메서드methodisLoaded()#0.0.8 부터since 0.0.8소스source

로드 되었는지 여부 반환.

Returns whether it is loaded.

반환Returnsboolean 로드 되었으면 참.True if loaded.

짝Counterpart: vanilla-engine AssetBase.is_loaded

AssetTypeenum

짝Counterpart: vanilla-engine AssetType

애셋 타입.

Asset type.

이름Name값Value설명Description
nonenone애셋 종류 없음.No asset type.
imageimage이미지 애셋.Image asset.
audioaudio오디오 애셋.Audio asset.
jsonjsonJSON 애셋.JSON asset.
texttext텍스트 애셋.Text asset.
fontfont글꼴 애셋.Font asset.
blobblob바이너리 덩어리 애셋.Binary blob asset.
bunchbunch묶음 애셋.Bundle asset.
visualvisual비주얼 애셋.Visual asset.