Ejemplo n.º 1
0
        public void LoadContent()
        {
            tileset     = game.Content.Load <Texture2D>("TS");
            tilesetmask = game.Content.Load <Texture2D>("TS_mask");
            rabbit      = new TextureSource(game.Content.Load <Texture2D>("rabbitanim"), new Rectangle(0, 0, 32, 32));
            rabbitmask  = game.Content.Load <Texture2D>("RabbitMask");

            spaz      = game.Content.Load <Texture2D>("spaz");
            spazWalk  = new TextureAnimation(spaz, 0, 0, 8, 50, 50);
            spazStand = new TextureAnimation(spaz, 5, 51, 5, 44, 50);

            spazSkidTrans = new TextureAnimation(spaz, 0, 101, 3, 57, 50);
            spazSkid      = new TextureAnimation(spaz, 57 * 3, 101, 3, 57, 50);

            spazJumpUpTrans   = new TextureAnimation(spaz, 0, 151, 3, 50, 52);
            spazJumpUp        = new TextureAnimation(spaz, 50 * 3, 151, 3, 50, 52);
            spazFallDownTrans = new TextureAnimation(spaz, 50 * 6, 151, 3, 50, 52);
            spazFallDown      = new TextureAnimation(spaz, 50 * 9, 151, 3, 50, 52);

            spazJumpSideTrans = new TextureAnimation(spaz, 0, 207, 3, 40, 43);
            spazJumpSide      = new TextureAnimation(spaz, 40 * 3, 207, 3, 40, 43);
            spazFallSideTrans = new TextureAnimation(spaz, 40 * 6, 207, 3, 40, 43);
            spazFallSide      = new TextureAnimation(spaz, 40 * 9, 207, 3, 40, 43);

            spazSpringJump = new TextureAnimation(spaz, 0, 258, 8, 41, 50);

            spazRunTrans = new TextureAnimation(spaz, 0, 308, 8, 53, 40);
            spazRun      = new TextureAnimation(spaz, 53 * 8, 308, 4, 53, 40);
        }
Ejemplo n.º 2
0
 public AnimationController(TextureAnimation animation)
     : base(animation.Parent, Rectangle.Empty)
 {
     this.current = animation;
     this.cFrame  = 0;
     this.end     = true;
 }
Ejemplo n.º 3
0
        public void Update(GameTime gt)
        {
            if (!end)
            {
                if (minTime > 0)
                {
                    minTime -= gt.ElapsedGameTime.Milliseconds;
                }

                msTime += gt.ElapsedGameTime.Milliseconds;

                if (msTime >= msSpeed)
                {
                    cFrame += ping ? -1 : 1;

                    if (cFrame < 0)
                    {
                        ping   = !ping;
                        cFrame = 0;
                    }

                    if (cFrame >= current.FrameCount)
                    {
                        if (loop == AnimationLoop.None || current == transition)
                        {
                            end    = true;
                            cFrame = current.FrameCount - 1;
                        }
                        else if (loop == AnimationLoop.Loop)
                        {
                            cFrame = 0;
                        }
                        else if (loop == AnimationLoop.Pingpong)
                        {
                            cFrame += ping ? 1 : -1;
                            ping    = !ping;
                        }
                    }

                    msTime -= msSpeed;
                }
            }

            if (end)
            {
                if (transition != null)
                {
                    this.current = animation;
                    Start(msSpeed, loop);
                    transition = null;
                }
            }
        }
Ejemplo n.º 4
0
        public void ChangeAnimationAndStart(TextureAnimation animation, int msSpeed, AnimationLoop loop, TextureAnimation transition)
        {
            if (this.animation != animation && minTime <= 0)
            {
                this.transition = transition;
                this.animation  = animation;
                this.current    = transition;
                this.minTime    = 0;
                Start(msSpeed, loop);

                Console.WriteLine("Anim: " + animation.GetHashCode());
            }
        }