Пример #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;
        }
Пример #2
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);
        }