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)); } }
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); }
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); } }