public ContentMetaData CreateMetaDataFromImageAnimation(string animationName, ImageAnimation animation) { var contentMetaData = new ContentMetaData(); SetDefaultValues(contentMetaData, animationName); contentMetaData.Type = ContentType.ImageAnimation; contentMetaData.Values.Add("DefaultDuration", animation.DefaultDuration.ToString(CultureInfo.InvariantCulture)); string images = ""; for (int index = 0; index < animation.Frames.Length; index++) images = AddImageToMetaData(animation, index, images); contentMetaData.Values.Add("ImageNames", images); return contentMetaData; }
public void CreateAnimationWithNewTextures() { var imageList = new[] { CreateImageWithColor(Color.Red), CreateImageWithColor(Color.CornflowerBlue), CreateImageWithColor(Color.Purple) }; var newMaterial = new ImageAnimation(imageList, 3).CreateMaterial( ContentLoader.Create<Shader>(new ShaderCreationData(ShaderFlags.Position2DTextured))); new Sprite(newMaterial, new Rectangle(0.25f, 0.25f, 0.5f, 0.5f)); }
private void ShowMultipleImageAnimation() { var imagelist = new List<Image>(); foreach (var image in ImageList) imagelist.Add(ContentLoader.Load<Image>(image)); animation = new ImageAnimation(imagelist.ToArray(), Duration); renderExample = new Sprite(new Material(ShaderFlags.Position2DTextured, "") { Animation = animation }, Rectangle.FromCenter(0.5f, 0.5f, 0.5f * imagelist[0].PixelSize.AspectRatio, 0.5f)); }
private static string AddImageToMetaData(ImageAnimation animation, int index, string images) { var image = animation.Frames[index]; if (images == "") images += (image.Name); else images += (", " + image.Name); return images; }