Ejemplo n.º 1
0
        public static Animation GenerateAnimation(string assetName, int frameWidth, int frameHeight, int animLength, double animSpeed)
        {
            Animation _Animation = new Animation();
                Texture2D _Texture = G.Content.Load<Texture2D>(assetName);

                int Cols = _Texture.Width / frameWidth;
                int Rows = _Texture.Height / frameHeight;

                _Animation.Frames = new List<Frame>();
                _Animation.CurrentFrame = 0;
                _Animation._TotalFrames = animLength; // Cols* Rows;

                for (int j = 0; j < Rows; j++)
                    for (int i = 0; i < Cols && j * Cols + i < animLength; i++)
                    {
                        Frame _Frame = new Frame(assetName, new Rectangle(i * frameWidth, j * frameHeight, frameWidth, frameHeight));
                        _Animation.Frames.Add(_Frame);
                    }

                _Animation.AnimationSpeed = animSpeed;
                return _Animation;
        }
Ejemplo n.º 2
0
 public Sprite(Frame frame, Vector2 startPosition)
 {
     _Frame = frame;
     _position = startPosition;
     _Color = Color.White;
 }