예제 #1
0
        public void ShowAnimation(IList <Bitmap> bitmaps, IList <double> delays, bool startPlaying)
        {
            fpsTimer = new FpsTimer(60);

            LoopControl.FpsTimer = fpsTimer;
            LoopControl.SetAndStartAction(control1, Go);
            drawManager = null;
            var myDrawManager = new DrawManager(control1, fpsTimer);

            if (bitmaps.Count != delays.Count)
            {
                throw new ArgumentException("must have same number of bitmaps as delays");
            }
            IList <Bitmap> oldBitmaps = null;

            if (flipBook != null)
            {
                oldBitmaps = flipBook.Bitmaps;
            }

            spriteManager = new SpriteManager(fpsTimer);
            sprite        = new JustSitThereSprite(new Point(0, 0));

            if (flipBook != null)
            {
                flipBook.FrameChanged -= flipBook_FrameChanged;
            }

            flipBook               = new FlipBook(bitmaps, delays);
            flipBook.Loop          = true;
            flipBook.Paused        = true;
            flipBook.FrameChanged += new EventHandler(flipBook_FrameChanged);
            sprite.AddAlteration(flipBook);
            spriteManager.AddObject(sprite);
            myDrawManager.AddDrawable(spriteManager);
            playButton.Enabled = true;

            drawManager = myDrawManager;

            trackBar1.Minimum = 0;
            trackBar1.Maximum = bitmaps.Count - 1;
            trackBar1.Value   = 0;

            if (startPlaying)
            {
                Play();
            }

            if (oldBitmaps != null)
            {
                foreach (Bitmap b in oldBitmaps)
                {
                    if (b != null)
                    {
                        b.Dispose();
                    }
                }
            }
        }
예제 #2
0
        public static Scene2D FlipBookTest()
        {
            const float FLIP_AMOUNT = (float)(180.0f * Math.PI / 180.0);

            const string FLIP_STATE = "Flip";

            string[] IDLE_IMAGE = new string[]
            {
                NINJA_ACTION + "Idle__000.png",
                NINJA_ACTION + "Idle__001.png",
                NINJA_ACTION + "Idle__002.png",
                NINJA_ACTION + "Idle__003.png",
                NINJA_ACTION + "Idle__004.png",
                NINJA_ACTION + "Idle__005.png",
                NINJA_ACTION + "Idle__006.png",
                NINJA_ACTION + "Idle__007.png",
                NINJA_ACTION + "Idle__008.png",
                NINJA_ACTION + "Idle__009.png"
            };

            string[] JUMP_IMAGE = new string[]
            {
                NINJA_ACTION + "Jump__000.png",
                NINJA_ACTION + "Jump__001.png",
                NINJA_ACTION + "Jump__002.png",
                NINJA_ACTION + "Jump__003.png",
                NINJA_ACTION + "Jump__004.png",
                NINJA_ACTION + "Jump__005.png",
                NINJA_ACTION + "Jump__006.png",
                NINJA_ACTION + "Jump__007.png",
                NINJA_ACTION + "Jump__008.png",
                NINJA_ACTION + "Jump__009.png"
            };

            FlipBook fb = new FlipBook(IDLE_IMAGE);

            State state = new State(FLIP_STATE);

            state.Add(new ActionSetRotate(FLIP_AMOUNT, 0.0f, 0.0f));
            state.Add(new ActionTranslate(0.5f));

            Behavior behavior = new Behavior();

            behavior.Add(state);

            Sprite sprite = new Sprite(fb, behavior);

            Scene2D scene = new Scene2D();

            scene.Add(sprite);

            return(scene);
        }
예제 #3
0
        /*******************/
        /*** Constructor ***/
        /*******************/

        public ActionFlipBook(FlipBook flipBook)
        {
            this.flipBook = flipBook;
        }
예제 #4
0
 public Sprite(FlipBook flipBook, Behavior behavior)
     : base(new MeshSprite(), behavior)
 {
     this.flipBook = flipBook;
 }
예제 #5
0
 public Sprite(string imagePath, Behavior behavior)
     : base(new MeshSprite(), behavior)
 {
     this.flipBook = new FlipBook(imagePath);
 }