Esempio n. 1
0
        public MyIconLabel(int x, int y, string text, MySprite[] Frames) : base(null, x, y, true)
        {
            // Check that the text is not null
            if (text == null)
            {
                throw new ArgumentException("The text of the MyIconLabel must not be null");
            }

            // Check that there is at least one frame
            if (Frames == null || Frames.Length == 0)
            {
                throw new ArgumentException("There has to be at least one frame if the picture is to be displayed by the MyIconLabel");
            }

            // Check that all frames have the exact same dimensions
            int frameWidth  = Frames[0].width;
            int frameHeight = Frames[0].height;

            foreach (MySprite Frame in Frames)
            {
                if (Frame.width != frameWidth || Frame.height != frameHeight)
                {
                    throw new ArgumentException("All the frames of the MyIconLabel must have the same width and height");
                }
            }

            // Create the icon
            AnimatedSprite = new MyStatefulAnimatedSprite(0, 0).WithState("Default", new MyStatefulAnimatedSpriteState(Frames));
            AddChild(AnimatedSprite);

            // Create the text label
            TextLabel = new MyTextLabel(text, 0, 0);
            AddChild(TextLabel);
        }
Esempio n. 2
0
 public MyBlinkingIcon(int x, int y, MySprite Graphics) : base(null, x, y, true)
 {
     Sprite = new MyStatefulAnimatedSprite(0, 0)
              .WithState("Off", new MyStatefulAnimatedSpriteState(new MySprite[] { Graphics }))
              .WithState("On", new MyStatefulAnimatedSpriteState(new MySprite[] {
         new MySprite(Graphics.width, Graphics.height, DrawingFrameworkUtils.NegateBoolArray(Graphics.data))
     }));
     AddChild(Sprite);
 }