public static AnimationBuilder SlideDownAnimation() { var animation = AnimationBuilder.New() .InsertFrame(0, new KeyFrame(0)) .InsertFrame(0.2f, new KeyFrame(-MathHelper.PiOver2)) .IsRelative(false); return(animation); }
public static AnimationBuilder DiveAnimation() { var animation = AnimationBuilder.New() .InsertFrame(0, new KeyFrame(0)) .InsertFrame(0.5f, new KeyFrame(MathHelper.PiOver2 + 0.1f)) .IsRelative(false) .AnimatePhysics(); return(animation); }
public static AnimationBuilder ClamberAnimation() { var animator = AnimationBuilder.New() .InsertFrame(0, new KeyFrame(new Vector2(0))) .InsertFrame(0.2f, new KeyFrame(new Vector2(0, -1))) .InsertFrame(0.3f, new KeyFrame(new Vector2(0.5f, -1f))) .IsRelative(true); return(animator); }
public static AnimationBuilder RollAnimation() { var animator = AnimationBuilder.New() .InsertFrame(0f, new KeyFrame(new Vector2(0f), 0, new Vector2(1))) .InsertFrame(0.2f, new KeyFrame(new Vector2(1f, 0.2f), MathHelper.Pi, new Vector2(1, 0.5f))) .InsertFrame(0.4f, new KeyFrame(new Vector2(2f, 0f), MathHelper.TwoPi, new Vector2(1))) .AnimatePhysics() .IsRelative(true); return(animator); }
protected override void LoadContent() { base.LoadContent(); scene.Start(); return; scene.Engine.AddSystem(new StayOnMouseSystem()); scene.Engine.AddSystem(new TestCollisionListener()); var cursor = new Entity(); cursor.Add(new Transform()); cursor.Add(new Sprite() { Texture = TextureUtil.CreateTexture(32, 32, Color.Black) }); cursor.Add(ColliderBuilder.New().BoxShape(0.5f, 0.5f).Create()); cursor.Add(new StayOnMouse()); var test = new Entity(); var transform = new Transform() { Position = new Vector2(1) }; test.Add(transform); var sprite = new Sprite() { Texture = TextureUtil.CreateTexture(64, 64, Color.Red) }; test.Add(sprite); var collider = ColliderBuilder.New().IsDynamic() .Create(); test.Add(collider); var camera = new Entity(); camera.Add(new Transform()); camera.Add(new Camera()); var animation = AnimationBuilder.New() .InsertFrame(0, new KeyFrame(new Vector2(-5, 0))) .InsertFrame(2, new KeyFrame(new Vector2(5, 0))) .InsertFrame(3, new KeyFrame(new Vector2(5, 2.5f))) .Reverses(true) .Loops(true) .AnimatePhysics() .Create(); var animationContainer = new AnimationContainer(); animationContainer.Animation.Add("test", animation); var animated = new Entity(); animated.Add(new Transform()); animated.Add(animationContainer); animated.Add(ColliderBuilder.New().IsDynamic().Create()); animated.Add(new Sprite() { Texture = TextureUtil.CreateTexture(64, 64, Color.Pink) }); scene.Engine.AddEntity(cursor); scene.Engine.AddEntity(test); scene.Engine.AddEntity(camera); scene.Engine.AddEntity(animated); scene.Engine.Systems.Get <CameraSystem>().ActiveCamera = camera; scene.Engine.MessageHub.SendMessage(new StartAnimationMessage(animated, "test")); }