forked from DragonBones/DragonBonesJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelloDragonBones.ts
43 lines (39 loc) · 1.56 KB
/
HelloDragonBones.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* How to use
* 1. Load data.
*
* 2. Parse data.
* factory.parseDragonBonesData();
* factory.parseTextureAtlasData();
*
* 3. Build armature.
* armatureDisplay = factory.buildArmatureDisplay("armatureName");
*
* 4. Play animation.
* armatureDisplay.animation.play("animationName");
*
* 5. Add armature to stage.
* addChild(armatureDisplay);
*/
class HelloDragonBones extends BaseDemo {
public constructor() {
super();
this._resources.push(
// "resource/mecha_1002_101d_show/mecha_1002_101d_show_ske.json",
"resource/mecha_1002_101d_show/mecha_1002_101d_show_ske.dbbin",
"resource/mecha_1002_101d_show/mecha_1002_101d_show_tex.json",
"resource/mecha_1002_101d_show/mecha_1002_101d_show_tex.png"
);
}
protected _onStart(): void {
const factory = dragonBones.EgretFactory.factory;
// factory.parseDragonBonesData(RES.getRes("resource/mecha_1002_101d_show/mecha_1002_101d_show_ske.json"));
factory.parseDragonBonesData(RES.getRes("resource/mecha_1002_101d_show/mecha_1002_101d_show_ske.dbbin"));
factory.parseTextureAtlasData(RES.getRes("resource/mecha_1002_101d_show/mecha_1002_101d_show_tex.json"), RES.getRes("resource/mecha_1002_101d_show/mecha_1002_101d_show_tex.png"));
const armatureDisplay = factory.buildArmatureDisplay("mecha_1002_101d", "mecha_1002_101d_show");
armatureDisplay.animation.play("idle");
armatureDisplay.x = 0.0;
armatureDisplay.y = 200.0;
this.addChild(armatureDisplay);
}
}