示例#1
0
 public Frame(float duration, int spriteX, int spriteY, SpriteSheetAnimations parent)
 {
     Duration      = duration;
     FrameLocation = new Rectangle(spriteX * (parent.Width + parent.Spacing) + parent.Margin,
                                   spriteY * (parent.Height + parent.Spacing) + parent.Margin,
                                   parent.Width, parent.Height);
 }
示例#2
0
        private void loadFromTileSet()
        {
            foreach (TmxTileset tileset in tilesets)
            {
                SpriteSheetAnimations spriteSheetAnimation = new SpriteSheetAnimations();
                spriteSheetAnimation.Width   = tileset.TileWidth;
                spriteSheetAnimation.Height  = tileset.TileHeight;
                spriteSheetAnimation.Margin  = tileset.Margin;
                spriteSheetAnimation.Spacing = tileset.Spacing;

                foreach (KeyValuePair <int, TmxTilesetTile> tile in tileset.Tiles)
                {
                    if (tile.Value.AnimationFrames.Count > 0)
                    {
                        AnimationTracker animationTracker = new AnimationTracker(spriteSheetAnimation);

                        string name = "Unamed " + tile.Key;
                        if (tile.Value.Properties.ContainsKey("Animation"))
                        {
                            name = tile.Value.Properties["Animation"];
                        }

                        foreach (TmxAnimationFrame animationFrame in tile.Value.AnimationFrames)
                        {
                            int x = (int)(animationFrame.Id % tileset.Columns);
                            int y = (int)Math.Floor(animationFrame.Id / (float)tileset.Columns);
                            animationTracker.AddFrame(animationFrame.Duration / (float)1000, x, y);
                        }

                        animationData[name] = animationTracker;
                    }
                }
            }
        }
示例#3
0
 public AnimationTracker(SpriteSheetAnimations parent)
 {
     this.Parent = parent;
     Frames      = new List <Frame>();
 }