public SimpleLoadingScreen()
 {
     _showAction = new FadeIn(.3f);
     _hideAction = _showAction.Reverse();
     _frame = SkidiGame.ResourceManager.GetFrame("$px");
     Scale = SkidiGame.ScreenBounds.Size.ToVector2();
 }
Example #2
0
 public void Draw(TextureFrame frame, Vector2 position, Color color, Vector2? origin = null,
     Vector2? scale = null,
     float rotation = 0f, SpriteEffects effect = SpriteEffects.None)
 {
     _spriteBatch.Draw(frame.Texture, _transform.Position + position, null, frame.Bounds, origin,
         _transform.Rotation + rotation, scale * _transform.Scale, color * _transform.Alpha,
         effect);
 }
Example #3
0
 public Button(ButtonFrames frames)
     : this()
 {
     _defaultFrame = frames.Default;
     _hoverFrame = frames.Hover;
     _downFrame = frames.Down;
     PointerState = PointerState.Default;
 }
Example #4
0
 public static ButtonFrames Create(TextureFrame defaultFrame, TextureFrame hoverFrame, TextureFrame downFrame)
 {
     return new ButtonFrames
     {
         Default = defaultFrame,
         Hover = hoverFrame,
         Down = downFrame
     };
 }
Example #5
0
            protected ButtonBase(ButtonFrames frames, TextureFrame icon)
                : base(frames, icon)
            {
                var iconOrigin = new Vector2(0, 4) * SkidiBirdGame.Scale;
                OriginState = new[] { -iconOrigin, -iconOrigin, iconOrigin };

                this.AddSignalHandler(CommonSignals.Ui.Enable, () => Enabled = true);
                this.AddSignalHandler(CommonSignals.Ui.Disable, () => Enabled = false);
            }
Example #6
0
 public IconButton(ButtonFrames frames, TextureFrame icon = null)
     : base(frames)
 {
     _icon = new Sprite
     {
         Frame = icon
     };
     Icon = _icon;
 }
Example #7
0
        public Background(Rectangle screenBounds, TextureFrame frame, VerticalAlign vertical = VerticalAlign.Middle, HorizontalAlign horizontal = 
            HorizontalAlign.Center)
        {
            if (screenBounds == null || screenBounds.Size == Point.Zero)
                throw new ArgumentNullException(nameof(screenBounds));

            if (frame == null)
                throw new ArgumentNullException(nameof(frame));

            _frame = frame;
            Color = Color.White;
            Alpha = 1f;

            var scaleFactor = Math.Max(screenBounds.Width/frame.Size.X,
                screenBounds.Height/frame.Size.Y);
            _scale = new Vector2(scaleFactor);

            var pos = new Vector2();
            var frameSize = frame.Size*scaleFactor;
            switch (vertical)
            {
                case VerticalAlign.Top:
                    pos.Y = 0;
                    break;
                case VerticalAlign.Bottom:
                    pos.Y = SkidiGame.ScreenBounds.Height - frameSize.Y;
                    break;
                case VerticalAlign.Middle:
                    pos.Y = (SkidiGame.ScreenBounds.Height - frameSize.Y)*.5f;
                    break;
            }

            switch (horizontal)
            {
                case HorizontalAlign.Left:
                    pos.X = 0;
                    break;
                case HorizontalAlign.Right:
                    pos.X = (SkidiGame.ScreenBounds.Width - frameSize.X);
                    break;
                case HorizontalAlign.Center:
                    pos.X = (SkidiGame.ScreenBounds.Width - frameSize.X)*.5f;
                    break;
            }

            Position = pos;
        }
Example #8
0
        protected virtual void SetFrame(TextureFrame frame)
        {
            if (_frame == frame)
                return;

            if (_frame == null)
            {
                _frame = frame;
                Size = frame.Size;
                Origin = Origin;
            }
            else
            {
                _frame = frame;
                if (_frame.Size.Equals(frame.Size))
                    return;
                Size = Size;
                Origin = Origin;
                Position = Position;
            }
        }
Example #9
0
 public static ButtonFrames Create(TextureFrame defaultFrame, TextureFrame downFrame)
 {
     return Create(defaultFrame, defaultFrame, downFrame);
 }
Example #10
0
 public void Draw(TextureFrame frame, Rectangle rect, Color color, Vector2 origin,
     float rotation = 0f, SpriteEffects effects = SpriteEffects.None, float layerDepth = 0f)
 {
     _spriteBatch.Draw(frame.Texture, rect, frame.Bounds, color, rotation, origin, effects, layerDepth);
 }
Example #11
0
 public Sprite(TextureFrame frame)
     : this()
 {
     Frame = frame;
 }
Example #12
0
        public AnimateActionState(Sprite target, Animate action)
            : base(target, action)
        {
            _sprite = target;
            Animation = action.Animation;
            SplitTimes = new Bag<float>(action.SplitTimes);

            _originalFrame = Animation.RestoreOriginalSprite ? target.Frame : null;
            _framesCount = Animation.Frames.Count;
            _nextFrame = 0;
            _executedLoops = 0;
        }
Example #13
0
 public void SetFrames(TextureFrame defaultFrame, TextureFrame hoverFrame, TextureFrame downFrame)
 {
     DefaultFrame = defaultFrame;
     HoverFrame = hoverFrame;
     DownFrame = downFrame;
 }
Example #14
0
 public AnimationFrame(TextureFrame spriteFrame, float delayUnits)
 {
     SpriteFrame = spriteFrame;
     DelayUnits = delayUnits;
 }