コード例 #1
0
        /// <summary>
        /// Adds a specific sprite animation
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="row">The row.</param>
        /// <param name="frames">The frames.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="isLooping">if set to <c>true</c> [is looping].</param>
        /// <param name="fps">The FPS.</param>
        public void AddAnimation(string name, int row,
                                 int frames, float rotation = 0, bool isLooping = true, float fps = 1 / 0.05f)
        {
            AnimationClass ac = new AnimationClass(name, isLooping, fps);

            ac.Rotation = rotation;
            Rectangle[] recs = new Rectangle[frames];
            for (int i = 0; i < frames; i++)
            {
                recs[i] = new Rectangle(i * width,
                                        (row - 1) * height, width, height);
            }
            ac.Frames     = frames;
            ac.Rectangles = recs;
            animations.Add(name, ac);
            if (this.animation == null)
            {
                this.animation  = name;
                SourceRectangle = animations[this.animation].Rectangles[FrameIndex];
                Rotation        = animations[this.animation].Rotation;
            }
        }
コード例 #2
0
 /// <summary>
 /// Adds a specific sprite animation
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="row">The row.</param>
 /// <param name="frames">The frames.</param>
 /// <param name="rotation">The rotation.</param>
 /// <param name="isLooping">if set to <c>true</c> [is looping].</param>
 /// <param name="fps">The FPS.</param>
 public void AddAnimation(string name, int row,
     int frames, float rotation = 0,bool isLooping = true, float fps = 1/0.05f)
 {
     AnimationClass ac = new AnimationClass(name,isLooping, fps);
     ac.Rotation = rotation;
     Rectangle[] recs = new Rectangle[frames];
     for (int i = 0; i < frames; i++)
     {
         recs[i] = new Rectangle(i * width, 
             (row - 1) * height, width, height);
     }
     ac.Frames = frames;
     ac.Rectangles = recs;
     animations.Add(name, ac);
     if (this.animation == null)
     {
         this.animation = name;
         SourceRectangle = animations[this.animation].Rectangles[FrameIndex];
         Rotation = animations[this.animation].Rotation;                
     }
 }