Esempio n. 1
0
        public void InitializeAnimation(int rows, int cols, int totalFrames, bool sideWays)
        {
            //Single animated background...
            //background list will contain only one texture...

            animatable = new AnimationsStruct();

            //Frame width and height...
            int frameWidth, frameHeight;

            if (background.Count > 0)
            {
                frameWidth  = background[0].Width / rows;
                frameHeight = background[0].Height / cols;
            }
            else
            {
                frameWidth  = 0;
                frameHeight = 0;
            }

            //setting up for animations...
            animatable.InitializeAnimations(rows, cols, totalFrames, frameWidth, frameHeight, sideWays);

            sourceRect = new Rectangle[1];

            sourceRect[0].X      = (int)animatable.getFrame().X;
            sourceRect[0].Y      = (int)animatable.getFrame().Y;
            sourceRect[0].Width  = frameWidth;
            sourceRect[0].Height = frameHeight;
        }
Esempio n. 2
0
        public void UpdateAnimated(GameTime gameTime, int frameRate)
        {
            if (animationTiming < frameRate)
            {
                animationTiming += 1;
            }
            else
            {
                animationTiming = 0;
            }

            if (animationTiming >= frameRate)
            {
                if (animatable.currentFrame <= animatable.totalFrames)
                {
                    animatable.currentFrame += 1;
                }
                else
                {
                    animatable.currentFrame = 0;
                }
            }

            sourceRect[0].X = (int)animatable.getFrame().X;
            sourceRect[0].Y = (int)animatable.getFrame().Y;
        }
Esempio n. 3
0
        public void InitializeAnimation(int totalFrames, int rows, int columns, bool sideWays, int frameRate)
        {
            animations = new AnimationsStruct();

            int frameWidth  = Sprite.Width / rows;
            int frameHeight = Sprite.Height / columns;

            animations.InitializeAnimations(rows, columns, totalFrames, frameWidth, frameHeight, sideWays);
            sourceRect    = new Rectangle((int)animations.getFrame().X, (int)animations.getFrame().Y, frameWidth, frameHeight);
            drawRectangle = new Rectangle((int)Position.X, (int)Position.Y, drawWidth, drawHeight);
        }
Esempio n. 4
0
 public void UpdateAnimations()
 {
     sourceRect.X = (int)animations.getFrame().X;
     sourceRect.Y = (int)animations.getFrame().Y;
 }