public AnimationPlayer(SkeletonAnimation animation) { Animation = animation; AnimationUpdates = new AnimationUpdater[Animation.BoneAnimations.Count]; SetTrans = new Transformation[Animation.BoneAnimations.Count]; currentFrame = 0; frameIndex = 0; int length = Animation.BoneAnimations.Count; for (int i = 0; i < length; i++) { AnimationUpdates[i] = new AnimationUpdater(Animation.BoneAnimations[i]); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> /// public void LoadAnimation() { skeletonAnimation = new SkeletonAnimation(); Keyframe ak= new Keyframe(); ak.trans.Position = new Vector2(0, 0); ak.trans.Rotation = 0f; ak.trans.Scale=new Vector2(1, 1); ak.FrameNumber=0; Keyframe ak2 = new Keyframe(); ak2.trans.Position = new Vector2(0, 0); ak2.trans.Rotation = 0f; ak2.trans.Scale = new Vector2(1, 1); ak2.FrameNumber = 19; Keyframe ak3 = new Keyframe(); ak3.trans.Position = new Vector2(0, 0); ak3.trans.Rotation = 0f; ak3.trans.Scale = new Vector2(1, 1); ak3.FrameNumber = 39; BoneAnimation ab = new BoneAnimation(); ab.Keyframes.Add(ak); //ab.Keyframes.Add(ak2); //ab.Keyframes.Add(ak3); ab.FrameLength = 40; ab.FPS = 12; skeletonAnimation.BoneAnimations.Add(ab); Keyframe bk = new Keyframe(); bk.trans.Position = new Vector2(0, 0); bk.trans.Rotation = MathHelper.PiOver4; bk.trans.Scale = new Vector2(1, 1); bk.FrameNumber = 0; Keyframe bk2 = new Keyframe(); bk2.trans.Position = new Vector2(0, 0); bk2.trans.Rotation = MathHelper.PiOver4/3; bk2.trans.Scale = new Vector2(1, 1); bk2.FrameNumber = 19; Keyframe bk3 = new Keyframe(); bk3.trans.Position = new Vector2(0, 0); bk3.trans.Rotation = MathHelper.PiOver4; bk3.trans.Scale = new Vector2(1, 1); bk3.FrameNumber = 39; BoneAnimation bb = new BoneAnimation(); bb.Keyframes.Add(bk); bb.Keyframes.Add(bk2); bb.Keyframes.Add(bk3); bb.FrameLength = 40; bb.FPS = 12; skeletonAnimation.BoneAnimations.Add(bb); Keyframe ck = new Keyframe(); ck.trans.Position = new Vector2(0, 0); ck.trans.Rotation = MathHelper.PiOver2 / 2; ck.trans.Scale = new Vector2(1, 1); ck.FrameNumber = 0; Keyframe ck2 = new Keyframe(); ck2.trans.Position = new Vector2(0, 0); ck2.trans.Rotation = MathHelper.PiOver2; ck2.trans.Scale = new Vector2(1, 1); ck2.FrameNumber = 19; Keyframe ck3 = new Keyframe(); ck3.trans.Position = new Vector2(0, 0); ck3.trans.Rotation = MathHelper.PiOver2 / 2f; ck3.trans.Scale = new Vector2(1, 1); ck3.FrameNumber = 39; Keyframe ck4 = new Keyframe(); ck4.trans.Position = new Vector2(0, 0); ck4.trans.Rotation = MathHelper.Pi; ck4.trans.Scale = new Vector2(1, 1); ck4.FrameNumber = 39; BoneAnimation cb = new BoneAnimation(); cb.Keyframes.Add(ck); cb.Keyframes.Add(ck2); cb.Keyframes.Add(ck3); //cb.Keyframes.Add(ck4); cb.FrameLength = 40; cb.FPS = 10; skeletonAnimation.BoneAnimations.Add(cb); animationPlayer = new AnimationPlayer(skeletonAnimation); }