Пример #1
0
 public AnimationTexture GetTexture(string name)
 {
     if (animationTextures.ContainsKey(name)){
         return animationTextures[name];
     }
     Texture2D texture = content.Load<Texture2D>(name);
     Color[,] colorArray = TextureTo2DArray(texture);
     AnimationTexture at = new AnimationTexture(texture, colorArray);
     animationTextures.Add(name, at);
     return at;
 }
Пример #2
0
 public Animation(AnimationTexture texture, int frameCount, int frametime, float scale, bool flip)
 {
     Initialize(texture, frameCount, frametime, scale, flip);
 }
Пример #3
0
        public void Initialize(AnimationTexture texture, int frameCount, int frametime, float scale, bool flip)
        {
            colorArray = texture.ColorArray;

            // Keep a local copy of the values passed in
            this.FrameWidth = texture.Texture.Width / frameCount;
            this.FrameHeight = texture.Texture.Height;
            this.frameCount = frameCount;
            this.frameTime = frametime;
            this.scale = scale;

            this.flip = flip;

            spriteStrip = texture.Texture;

            // Set the time to zero
            elapsedTime = 0;
            currentFrame = 0;
            biggestSide = Math.Max((frameWidth * scale), (frameHeight * scale));
            boundingBox = new Rectangle(0, 0, (int)(biggestSide), (int)(biggestSide));

            // Set the Animation to active by default
            Active = true;
        }