Beispiel #1
0
        public void Draw(SpriteBatch batch)
        {
            if (Frames.Count == 0 || CompleteAnimation)
            {
                return;
            }
            AeAnimationFrame frame = Frames[_currentFrame];
            Rectangle        destinationRectangle;
            Rectangle        sourceRectangle;

            destinationRectangle.X      = (int)Math.Floor(Parent.Owner.Transform.X);
            destinationRectangle.Y      = (int)Math.Floor(Parent.Owner.Transform.Y);
            destinationRectangle.Width  = frame.FrameWidth;
            destinationRectangle.Height = frame.FrameHeight;

            sourceRectangle.X      = frame.FrameX;
            sourceRectangle.Y      = frame.FrameY;
            sourceRectangle.Width  = frame.FrameWidth;
            sourceRectangle.Height = frame.FrameHeight;

            Vector2 rotationCenter = Vector2.Zero;

            rotationCenter.X = Parent.Owner.Transform.RotationCenter.X * sourceRectangle.Width;
            rotationCenter.Y = Parent.Owner.Transform.RotationCenter.Y * sourceRectangle.Height;

            //fix their positioning if they have a rotation offset
            destinationRectangle.X += (int)rotationCenter.X;
            destinationRectangle.Y += (int)rotationCenter.Y;

            batch.Draw(
                Texture,
                destinationRectangle,
                sourceRectangle,
                Parent.RenderColor.CurrentColor,
                Parent.Owner.Transform.Orientation,
                rotationCenter,
                SpriteEffects.None,
                0);
        }
Beispiel #2
0
 public void AddFrame(AeAnimationFrame frame)
 {
     Frames.Add(frame);
 }