kagurajs - v0.2.7 / Exports / Asset
Class: Asset
Kagura asset class.
Remarks
It is KaguraJS asset class. It does manage game asset. import:
ts
import { Asset } from "kagurajs"
Example
ts
// On Vite
import { Asset } from "kagurajs"
import cat from "./assets/cat.png"
const catAsset = new Asset().fromURL(cat) // Load asset via Vite import.
Example
ts
// Not use esm
const { Asset } = kagura
const catAsset = new Asset().fromURL("/assets/cat.png") // Load asset via raw URL.
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new Asset()
Defined in
Properties
#blobData
• Private
#blobData: Blob
Defined in
#blobURL
• Private
#blobURL: URL
Defined in
Accessors
blob
• get
blob(): Blob
Returns
Blob
Defined in
url
• get
url(): URL
Returns asset's URL.
Returns
URL
A asset's URL
Defined in
Methods
fromBlob
▸ fromBlob(blob
): Asset
Load asset from Blob.
Parameters
Name | Type | Description |
---|---|---|
blob | Blob | Load blob Object |
Returns
Defined in
fromResponse
▸ fromResponse(response
): Promise
<Asset
>
Parameters
Name | Type |
---|---|
response | Response |
Returns
Promise
<Asset
>
Defined in
fromURL
▸ fromURL(url
): Promise
<Asset
>
Load asset from URL.
Parameters
Name | Type |
---|---|
url | string | URL |
Returns
Promise
<Asset
>
Example
ts
const assets = new Asset().fromURL(url)
Defined in
getDataUrl
▸ getDataUrl(): Promise
<string
>
Returns
Promise
<string
>
Defined in
getPixiTexure
▸ getPixiTexure(): Promise
<Texture
<Resource
>>
Returns
Promise
<Texture
<Resource
>>