TextureAtlas
Namespace: MonineEngine.Graphics
Handles a texture atlas with a source Texture2D and
public class TextureAtlas
Inheritance Object → TextureAtlas
Attributes NullableContextAttribute, NullableAttribute
Properties
Texture
The of the atlas.
public Texture2D Texture { get; set; }
Property Value
Texture2D
Constructors
TextureAtlas()
Creates a new TextureAtlas
public TextureAtlas()
TextureAtlas(Texture2D)
public TextureAtlas(Texture2D texture)
Parameters
texture Texture2D
Methods
AddRegion(String, Int32, Int32, Int32, Int32)
Creates a new region and adds it to the texture atlas.
public void AddRegion(string name, int x, int y, int width, int height)
Parameters
name String
The name to give the texture region.
x Int32
The top-left x-coordinate position of the region boundary relative to the top-left corner of the source texture boundary.
y Int32
The top-left y-coordinate position of the region boundary relative to the top-left corner of the source texture boundary.
width Int32
The width, in pixels, of the region.
height Int32
The height, in pixels, of the region.
GetRegion(String)
Gets the region from this texture atlas with the specified name.
public TextureRegion GetRegion(string name)
Parameters
name String
The name of the region to retrieve.
Returns
TextureRegion
The TextureRegion with the specified name.
RemoveRegion(String)
Removes the region from this texture atlas with the specified name.
public bool RemoveRegion(string name)
Parameters
name String
The name of the region to remove.
Returns
AddAnimation(String, Animation)
Creates a new animation and adds it to the atlas.
public void AddAnimation(string animationName, Animation animation)
Parameters
animationName String
The name of the animation to add.
animation Animation
The animation to add.
GetAnimation(String)
Gets the animation from this texture atlas with the specified name.
public Animation GetAnimation(string animationName)
Parameters
animationName String
The name of the animation to retrieve.
Returns
Animation
The animation with the specified name.
RemoveAnimation(String)
Removes the animation from this texture atlas with the specified name.
public bool RemoveAnimation(string animationName)
Parameters
animationName String
The name of the animation to remove.
Returns
Boolean
true, if the animation was successfully removed. If removal failed, returns false.
Clear()
Removes all regions from this texture atlas.
public void Clear()
FromFile(ContentManager, String, Boolean)
Creates a new texture atlas based on an XML file that defines one.
public static TextureAtlas FromFile(ContentManager content, string fileName, bool loadAnimations)
Parameters
content ContentManager
The content manager used to load the texture for the atlas.
fileName String
The path to the XML file, relative to the content root directory.
loadAnimations Boolean
Whether animations should be loaded from the file, in addition to the regions.
Returns
TextureAtlas
The texture atlas created by this method.
CreateSprite(String)
Creates a new Sprite using the region from this atlas with the specified name.
public Sprite CreateSprite(string regionName)
Parameters
regionName String
The name of the region to create the Sprite with.
Returns
Sprite
A new Sprite using the texture region with the specified name.
CreateAnimatedSprite(String)
Creates a new AnimatedSprite using the animation from the atlas with the specified name.
public AnimatedSprite CreateAnimatedSprite(string animationName)
Parameters
animationName String
The name of the animation to use.
Returns
AnimatedSprite
A new AnimatedSprite using the animation with the specified name.