@antha/asset 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,55 @@
|
|
|
1
1
|
# @antha/asset
|
|
2
2
|
|
|
3
|
-
A pre-built [Antha](https://www.npmjs.com/package/
|
|
3
|
+
A pre-built [Antha game engine](https://www.npmjs.com/package/@antha/engine) mod for defining, caching, and cleaning up game assets.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
npm i @antha/asset
|
|
9
9
|
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
<!-- example-link: src/readme-examples/loading-asset.example.ts -->
|
|
14
|
+
|
|
15
|
+
```TypeScript
|
|
16
|
+
import {AnthaEngine, defineAnthaMod} from '@antha/engine';
|
|
17
|
+
import {type AnthaAssetModState, createAnthaAssetMod, defineAsset} from '@antha/asset';
|
|
18
|
+
|
|
19
|
+
type GameState = AnthaAssetModState & {
|
|
20
|
+
hasLoadedTitle: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const titleAsset = defineAsset({
|
|
24
|
+
name: 'title',
|
|
25
|
+
maxProgress: 1,
|
|
26
|
+
load({incrementProgressCallback}) {
|
|
27
|
+
incrementProgressCallback();
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
value: 'Antha',
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const engine = new AnthaEngine<GameState>({
|
|
35
|
+
initState: {
|
|
36
|
+
hasLoadedTitle: false,
|
|
37
|
+
},
|
|
38
|
+
mods: [
|
|
39
|
+
createAnthaAssetMod(),
|
|
40
|
+
defineAnthaMod<GameState>({
|
|
41
|
+
modName: 'game-logic',
|
|
42
|
+
async execute({state}) {
|
|
43
|
+
if (state.assetLoader && !state.hasLoadedTitle) {
|
|
44
|
+
state.hasLoadedTitle = true;
|
|
45
|
+
await state.assetLoader.bulkLoadAssets([
|
|
46
|
+
titleAsset,
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
engine.startLoop();
|
|
55
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/asset",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "An Antha mod for handling asset loading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"pixi.js": "^8.19.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@antha/engine": "^0.1.
|
|
50
|
+
"@antha/engine": "^0.1.1",
|
|
51
51
|
"element-vir": ">=26"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|