Exemple #1
0
 public Image(string image, Rectangle rect, Vector2 anchorPosition, Vector2 anchorSize) : this(new Core.Transform())
 {
     this.image = new Graphics.Sprite(this, image, new List <Rectangle> {
         rect
     });
     this.anchorPosition = anchorPosition;
     this.anchorSize     = anchorSize;
 }
Exemple #2
0
            protected override Task <ResultStatus> DoCommandOverride(ICommandContext commandContext)
            {
                var assetManager = new AssetManager();

                var imageGroupData = new SpriteSheet {
                    Sprites = new List <Graphics.Sprite>()
                };

                // add the sprite data to the sprite list.
                foreach (var image in AssetParameters.SheetAsset.Sprites)
                {
                    var newImage = new Graphics.Sprite
                    {
                        Name          = image.Name,
                        Region        = image.TextureRegion,
                        IsTransparent = AssetParameters.SheetAsset.Alpha != AlphaFormat.None, // todo analyze texture region texture data to auto-determine alpha?
                        Orientation   = image.Orientation,
                        Center        = image.Center + (image.CenterFromMiddle ? new Vector2(image.TextureRegion.Width, image.TextureRegion.Height) / 2 : Vector2.Zero),
                        Borders       = image.Borders,
                        PixelsPerUnit = new Vector2(image.PixelsPerUnit)
                    };

                    int imageIndex;
                    if (ImageToTextureIndex.TryGetValue(image, out imageIndex))
                    {
                        newImage.Texture = AttachedReferenceManager.CreateSerializableVersion <Texture>(Guid.Empty, SpriteSheetAsset.BuildTextureUrl(Url, ImageToTextureIndex[image]));
                    }
                    else
                    {
                        commandContext.Logger.Warning("Image '{0}' has an invalid image source file '{1}', resulting texture will be null.", image.Name, image.Source);
                    }

                    imageGroupData.Sprites.Add(newImage);
                }

                // save the imageData into the data base
                assetManager.Save(Url, imageGroupData);

                return(Task.FromResult(ResultStatus.Successful));
            }
 public void Draw(Graphics.Sprite sfmlSprite)
 {
 }