コード例 #1
0
        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"));
        }