示例#1
0
 public SpriteTemplate(string name, string gridDir, int gridWidth, int gridHeight, bool animated)
 {
     Name = name;
     Sheet = gridDir;
     this.Animated = animated;
     Size = new Rectangle(0, 0, Sprite.SpriteSheets[gridDir].Bounds.Width / gridWidth, Sprite.SpriteSheets[sheet].Bounds.Height / gridHeight);
     Frames = new Frame[gridWidth * gridHeight];
     for (int x = 0; x < gridWidth; x++)
         for (int y = 0; y < gridHeight; y++)
             Frames[x + y * gridWidth] = new Frame(new Rectangle(x * Size.Width, y * Size.Height, Size.Width, Size.Height));
     Animation idleAnimation = new Animation(Sprite.IDLE, 0, 1, new int[] { 0 }, false, true);
     animations[Sprite.IDLE] = idleAnimation;
     Sprite.SpriteTemplates[Name] = this;
 }
示例#2
0
        public SpriteTemplate(string name, string sheetDir, Rectangle? spriteSize, Color? backgroundColor, bool animated)
        {
            Name = name;
            Sheet = sheetDir;
            this.Animated = animated;
            Size = spriteSize ?? new Rectangle(0, 0, 0, 0);

            Color[] firstPixel = new Color[1];
            Sprite.SpriteSheets[sheet].GetData<Color>(0, new Rectangle(0, 0, 1, 1), firstPixel, 0, 1);
            Color background = backgroundColor ?? firstPixel[0];

            getFrames(background);
            Animation idleAnimation = new Animation(Sprite.IDLE, 0, 1, new int[] { 0 }, false, true);
            animations[Sprite.IDLE] = idleAnimation;
            Sprite.SpriteTemplates[Name] = this;
        }
示例#3
0
 public void addAnimation(Animation animation)
 {
     animations[animation.Name] = animation;
     animation.Parent = this;
 }
示例#4
0
 public void addAnimation(Animation animation)
 {
     animations[animation.Name] = animation;
 }
示例#5
0
 internal Animation copy()
 {
     Animation returnCopy = new Animation(Name, frames.ToArray(), times.ToArray(), Loops);
     returnCopy.Paused = Paused;
     returnCopy.Speed = Speed;
     return returnCopy;
 }