Exemple #1
0
        /// <summary>
        /// Constructs the internal sprites needed for our demo.
        /// </summary>
        public DragMode()
        {
            // Create the fragment marbles
            int rows = 3;
            int cols = 3;
            int sx   = (SpriteDemosMain.Size.Width - cols * 50) / 2;
            int sy   = (SpriteDemosMain.Size.Height - rows * 50) / 2;
            SurfaceCollection   m1    = LoadMarble("marble1");
            SurfaceCollection   m2    = LoadMarble("marble2");
            AnimationCollection anim1 = new AnimationCollection();

            anim1.Add(m1);
            AnimationCollection anim2 = new AnimationCollection();

            anim2.Add(m2);
            AnimationDictionary frames = new AnimationDictionary();

            frames.Add("marble1", anim1);
            frames.Add("marble2", anim2);

            DragSprite dragSprite;

            for (int i = 0; i < cols; i++)
            {
                Thread.Sleep(10);
                for (int j = 0; j < rows; j++)
                {
                    dragSprite = new DragSprite(frames["marble1"],
                                                new Point(sx + i * 50, sy + j * 50)
                                                );
                    dragSprite.Animations.Add("marble1", anim1);
                    dragSprite.Animations.Add("marble2", anim2);
                    dragSprite.Animate = true;
                    if (Randomizer.Next(2) == 1)
                    {
                        dragSprite.AnimateForward = false;
                    }
                    Thread.Sleep(10);
                    Sprites.Add(dragSprite);
                }
            }
        }
Exemple #2
0
        //  Add an animation to the set. The name must be unique.
        public void AddAnimation(Animation anim)
        {
            Animation oot;

            if (animations_.TryGetValue(anim.Name, out oot))
            {
                throw new System.ArgumentException(
                          String.Format("An animation with the name {0} already exists in AnimationSet.AddAnimation()",
                                        anim.Name), "anim");
            }
            animations_.Add(anim.Name, anim);
        }
Exemple #3
0
        /// <summary>
        /// Constructs the internal sprites needed for our demo.
        /// </summary>
        public DragMode()
        {
            // Create the fragment marbles
            int rows = 3;
            int cols = 3;
            int sx = (SpriteDemosMain.Size.Width - cols * 50) / 2;
            int sy = (SpriteDemosMain.Size.Height - rows * 50) / 2;
            SurfaceCollection m1 = LoadMarble("marble1");
            SurfaceCollection m2 = LoadMarble("marble2");
            AnimationCollection anim1 = new AnimationCollection();
            anim1.Add(m1);
            AnimationCollection anim2 = new AnimationCollection();
            anim2.Add(m2);
            AnimationDictionary frames = new AnimationDictionary();
            frames.Add("marble1", anim1);
            frames.Add("marble2", anim2);

            DragSprite dragSprite;
            for (int i = 0; i < cols; i++)
            {
                Thread.Sleep(10);
                for (int j = 0; j < rows; j++)
                {
                    dragSprite = new DragSprite(frames["marble1"],
                        new Point(sx + i * 50, sy + j * 50)
                        );
                    dragSprite.Animations.Add("marble1", anim1);
                    dragSprite.Animations.Add("marble2", anim2);
                    dragSprite.Animate = true;
                    if (Randomizer.Next(2) == 1)
                    {
                        dragSprite.AnimateForward = false;
                    }
                    Thread.Sleep(10);
                    Sprites.Add(dragSprite);
                }
            }
        }