Esempio n. 1
0
        public void AddAnimation(string animationKey, string textureName,
            FrameRange frameRange, int frameWidth, int frameHeight,
            int numberOfFrames, int framesPerSecond)
        {
            Animation animation = new Animation(textureName, frameRange,
                framesPerSecond);

            if (!textures.ContainsKey(textureName))
            {
                textures.Add(textureName, Game.Content.Load<Texture2D>(
                    contentPath + textureName));
            }

            animation.FrameWidth = frameWidth;
            animation.FrameHeight = frameHeight;
            animation.NumberOfFrames = numberOfFrames;
            animation.FramesPerRow = textures[textureName].Width / frameWidth;

            if (animations.ContainsKey(animationKey))
            {
                animations[animationKey] = animation;
            }
            else
            {
                animations.Add(animationKey, animation);
            }
        }
Esempio n. 2
0
 public Animation(string textureName, FrameRange frameRange,
     int framesPerSecond)
 {
     this.textureName = textureName;
     this.frameRange = frameRange;
     this.framesPerSecond = framesPerSecond;
     this.timePerFrame = 1.0f / (float)framesPerSecond;
     this.Frame = 0;
 }