MCPcopy
hub / github.com/EngoEngine/engo / TestAnimationComponentSelectAnimationByAction

Function TestAnimationComponentSelectAnimationByAction

common/animation_test.go:83–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestAnimationComponentSelectAnimationByAction(t *testing.T) {
84 drawables := []Drawable{
85 &TestDrawable{0},
86 &TestDrawable{1},
87 &TestDrawable{2},
88 }
89 ac := NewAnimationComponent(drawables, 0.1)
90 firstFrames := []int{0, 1, 2}
91 secondFrames := []int{1, 2, 1, 0}
92 actions := []*Animation{
93 {
94 Name: "ZeroOneTwo",
95 Frames: firstFrames,
96 },
97 {
98 Name: "OneTwoOneZero",
99 Frames: secondFrames,
100 },
101 }
102 ac.AddAnimations(actions)
103 ac.SelectAnimationByAction(actions[0])
104 for i, frame := range ac.CurrentAnimation.Frames {
105 if frame != firstFrames[i] {
106 t.Errorf("Animation ZeroOneTwo was not set to current animation after SelectAnimationByAction")
107 }
108 }
109 ac.SelectAnimationByAction(actions[1])
110 for i, frame := range ac.CurrentAnimation.Frames {
111 if frame != secondFrames[i] {
112 t.Errorf("Animation OneTwoOneZero was not set to current animation after SelectAnimationByAction")
113 }
114 }
115}
116
117func TestAnimationComponentAddDefaultAnimation(t *testing.T) {
118 drawables := []Drawable{

Callers

nothing calls this directly

Calls 3

AddAnimationsMethod · 0.95
NewAnimationComponentFunction · 0.85

Tested by

no test coverage detected