Пример #1
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            var spring = new SimpleSpring()
            {
                Length    = size.y / 2,
                MaxLength = (size.y / 2) + (size.y / 4),
                MinLength = size.y / 4,
                Position  = new Vector2(size.x / 2, 0)
            };

            spring.SetMover(new Mover(), new Vector2(0, size.y / 2));

            AddChild(spring);
        }
Пример #2
0
        public override void _Ready()
        {
            var size                   = GetViewportRect().Size;
            var springStep             = size.x / SpringCount;
            var springPerSpringSurface = size.x / SprintChildSurfaceRatio;
            var springPerSpringOffset  = springPerSpringSurface / SpringPerSpring;

            for (int x = 0; x < SpringCount; ++x)
            {
                var spring = new SimpleSpring();
                var mover  = new Mover();

                spring.Length    = (size.y / 4) + (x * SpringSeparation);
                spring.MaxLength = size.y / 2;
                spring.MinLength = size.y / 8;
                spring.Position  = new Vector2((springStep / 2) + (springStep * x), 0);

                spring.SetMover(mover, new Vector2(0, size.y / 4));
                AddChild(spring);

                for (int s = 0; s < SpringPerSpring; ++s)
                {
                    var cSpring = new SimpleSpring()
                    {
                        ShowBehindParent = true,
                        Length           = (size.y / 4) + (s * SpringSeparation),
                        MaxLength        = size.y / 2,
                        MinLength        = size.y / 8,
                        Position         = Vector2.Zero
                    };

                    cSpring.SetMover(new Mover(), new Vector2((springPerSpringOffset * s) - (springPerSpringSurface / 2) + (springPerSpringOffset / 2), size.y / 4));
                    mover.AddChild(cSpring);
                }
            }
        }