Class Sprite
A sprite.
[DataContract]
[ContentSerializer(typeof(DataContentSerializer<Sprite>))]
[DataSerializerGlobal(typeof(ReferenceSerializer<Sprite>), null, DataSerializerGenericMode.None, false, false, Profile = "Content")]
public class Sprite
- Inheritance
-
Sprite
- Extension Methods
Constructors
Sprite()
Create an instance of Sprite with a unique random name.
public Sprite()
Sprite(Texture)
Create an instance of Sprite from the provided Texture. A unique Id is set as name and the Region is initialized to the size of the whole texture.
public Sprite(Texture texture)
Parameters
texture
TextureThe texture to use as texture
Sprite(string)
Creates an empty Sprite having the provided name.
public Sprite(string fragmentName)
Parameters
fragmentName
stringName of the fragment
Sprite(string, Texture)
Creates a Sprite having the provided texture and name. The region size is initialized with the whole size of the texture.
public Sprite(string fragmentName, Texture texture)
Parameters
Fields
DefaultPixelsPerUnit
public const int DefaultPixelsPerUnit = 100
Field Value
Properties
Borders
Gets or sets size of the unstretchable borders of source sprite in pixels.
public Vector4 Borders { get; set; }
Property Value
Remarks
Borders size are ordered as follows X->Left, Y->Top, Z->Right, W->Bottom.
Center
The position of the center of the image in pixels.
public Vector2 Center { get; set; }
Property Value
HasBorders
Gets the value indicating if the image has unstretchable borders.
public bool HasBorders { get; }
Property Value
IsTransparent
Gets or sets the value indicating if the fragment contains transparent regions.
public bool IsTransparent { get; set; }
Property Value
Name
Gets or sets the name of the image fragment.
public string Name { get; set; }
Property Value
Orientation
Gets or sets the rotation to apply to the texture region when rendering the Sprite
public virtual ImageOrientation Orientation { get; set; }
Property Value
PixelsPerUnit
Gets or sets the pixels per scene unit of the sprite.
public Vector2 PixelsPerUnit { get; set; }
Property Value
Remarks
The value is clamped to a strictly positive value.
Region
The rectangle specifying the region of the texture to use as fragment.
public RectangleF Region { get; set; }
Property Value
Size
Gets the size of the sprite in scene units. Note that the orientation of the image is taken into account in this calculation.
public Vector2 Size { get; }
Property Value
SizeInPixels
Gets the size of the sprite in pixels. Note that the orientation of the image is taken into account in this calculation.
public Vector2 SizeInPixels { get; }
Property Value
Texture
The texture in which the image is contained
public Texture Texture { get; set; }
Property Value
Methods
Clone()
Clone the current sprite.
public Sprite Clone()
Returns
- Sprite
A new instance of the current sprite.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.