예제 #1
0
        internal GMSpriteFrame(GMSprite sprite)
        {
            if (sprite == null)
            {
                throw new ArgumentNullException(nameof(sprite));
            }

            Sprite         = sprite;
            CompositeImage = GMSpriteImage.Create(this, null);

            layers = new List <GMSpriteImage>();
            foreach (var layer in sprite.Layers)
            {
                layers.Add(GMSpriteImage.Create(this, layer));
            }
        }
예제 #2
0
            public GMSpriteImageLayer Create()
            {
                var layer = new GMSpriteImageLayer(sprite)
                {
                    Id   = Guid.NewGuid(),
                    Name = layers.Count == 0 ? "default" : $"Layer {layers.Count}"
                };

                layers.Insert(0, layer);

                foreach (var frame in sprite.Frames)
                {
                    frame.layers.Insert(0, GMSpriteImage.Create(frame, layer));
                }

                return(layer);
            }
예제 #3
0
        internal override void Deserialize(ModelBase model)
        {
            var frame = (GMSpriteFrameModel)model;

            Id             = frame.id;
            CompositeImage = GMSpriteImage.FromExisting(
                frame.compositeImage.id,
                this,
                Sprite.Layers.Get(frame.compositeImage.LayerId)
                );

            foreach (var imageModel in frame.images)
            {
                var image = GMSpriteImage.FromExisting(
                    imageModel.id,
                    this,
                    Sprite.Layers.Get(imageModel.LayerId)
                    );

                layers.Add(image);
            }
        }