-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (54 loc) · 1.61 KB
/
main.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"dragonBones/bone"
"image/color"
"os"
"github.com/EngoEngine/ecs"
"github.com/EngoEngine/engo"
"github.com/EngoEngine/engo/common"
)
type DragonBoneTest struct {
}
type ArmatureEntity struct {
ecs.BasicEntity
*bone.ArmatureDisplay
}
func (s *DragonBoneTest) Type() string {
return "DragonBoneTest"
}
func (s *DragonBoneTest) Preload() {
bone.Factory.SetAssetPath("Assets")
bFile, _ := os.Open("Assets/mecha_1002_101d_show_ske.dbbin")
tFile, _ := os.Open("Assets/mecha_1002_101d_show_tex.json")
bone.Factory.LoadDragonBonesData(bFile, "", 1.0)
bone.Factory.LoadTextureAtlasData(tFile, "", 1.0)
}
func (s *DragonBoneTest) Setup(u engo.Updater) {
w := u.(*ecs.World)
w.AddSystem(&common.RenderSystem{})
w.AddSystem(&common.FPSSystem{Display: true})
w.AddSystem(&bone.DragonBoneSystem{})
common.SetBackground(color.White)
armatureDisplay := bone.Factory.BuildArmatureDisplay("mecha_1002_101d", "mecha_1002_101d_show")
armatureEntity := ArmatureEntity{BasicEntity: ecs.NewBasic(), ArmatureDisplay: armatureDisplay}
armatureDisplay.RenderComponent.Drawable = armatureDisplay
armatureDisplay.SpaceComponent = common.SpaceComponent{
Position: engo.Point{X: 400, Y: 500},
}
for _, system := range w.Systems() {
switch sys := system.(type) {
case *bone.DragonBoneSystem:
sys.Add(&armatureEntity.BasicEntity, &armatureDisplay.RenderComponent, &armatureDisplay.SpaceComponent)
}
}
armatureDisplay.GetAnimation().Play("idle")
}
func main() {
opts := engo.RunOptions{
Title: "DragonBones Test",
Width: 800,
Height: 600,
FPSLimit: 120,
}
engo.Run(opts, &DragonBoneTest{})
}