Otter  0.9.88
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Spritemap< TAnimType > Class Template Reference

Graphic that is used for an animated sprite sheet. More...

Inherits Otter.Image.

Public Member Functions

 Spritemap (string source, int width, int height)
 Create a new Spritemap from a file path. More...
 
 Spritemap (Texture texture, int width, int height)
 Create a new Spritemap from a Texture. More...
 
 Spritemap (AtlasTexture texture, int width, int height)
 Create a new Spritemap from an AtlasTexture. More...
 
void Add (TAnimType a, Anim anim)
 Add an animation to the list of Anims. More...
 
Anim Add (TAnimType a, string frames, float framedelays)
 Adds an animation using a string for frames and a single value for frame delay. More...
 
Anim Add (TAnimType a, string frames, string framedelays)
 Add an animation using a string for frames and a string for framedelays. More...
 
Anim Add (TAnimType a, int[] frames, float[] frameDelay=null)
 Add an animation to the sprite. More...
 
Anim Add (TAnimType a, int[] frames, float framedelays)
 Adds an animation using an array for frames and a single value for frame delay. More...
 
override void Update ()
 Updates the animation. The sprite will not animate without this. More...
 
void Play (TAnimType a, bool forceReset=true)
 Play the desired animation. More...
 
void Buffer (TAnimType a)
 Buffers an animation but does not play it. Call Play() with no arguments to play the buffered animation. More...
 
void Play (bool forceReset=true)
 Plays an animation. If no animation is specified, play the buffered animation. More...
 
Anim Anim (TAnimType a)
 Get the animation with a specific key. More...
 
void Pause ()
 Pause the playback of the animation. More...
 
void Resume ()
 Resume the animation from the current position. More...
 
void Stop ()
 Stop playback. This will reset the animation to the first frame. More...
 
void SetFrame (int frame)
 Set the current animation to a specific frame. More...
 
void FreezeFrame (int frame)
 Set the current animation to a specific frame and pause. More...
 
void SetGlobalFrame (int frame)
 Set the sprite to a frame on the sprite sheet itself. This will disable the current animation! More...
 
void Reset ()
 Resets the current animation back to the first frame. More...
 
void Clear ()
 Clear the list of animations. More...
 
- Public Member Functions inherited from Otter.Image
 Image (string source=null)
 Creates a new Image using a filepath to a texture. More...
 
 Image (Texture texture)
 Creates a new Image using a Texture. More...
 
 Image (AtlasTexture texture)
 Creates a new Image using an AtlasTexture. More...
 
 Image (int width, int height)
 Creates a new Image using a specified width and height. More...
 
- Public Member Functions inherited from Otter.Graphic
Transformation AddTransform (Transformation transform)
 
Transformation AddTransform (Vector2 translation, Vector2 scale, Vector2 origin, float rotation)
 
Transformation AddTransform ()
 
Transformation RemoveTransformation (Transformation transform)
 
Transformation PopTransformation ()
 
virtual void ClearShader ()
 Removes the shader from the graphic. More...
 
void SetPosition (float x, float y)
 Set the position of the Graphic. More...
 
void SetPosition (Graphic g, float offsetX=0, float offsetY=0)
 Set the position of the Graphic. More...
 
void SetPosition (Vector2 xy)
 Set the position of the Graphic. More...
 
void SetOrigin (float x, float y)
 Set the origin of the Graphic. More...
 
void SetOrigin (Vector2 xy)
 Set the origin of the Graphic. More...
 
void SetTexture (string path)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
void SetTexture (Texture texture)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
void SetTexture (AtlasTexture atlasTexture)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
virtual void CenterOrigin ()
 Centers the graphic origin. More...
 
virtual void CenterOriginZero ()
 Centers the graphic origin while retaining its relative position. More...
 
virtual void Render (float x=0, float y=0)
 Draws the graphic. More...
 

Public Attributes

float Speed = 1f
 The playback speed of all animations. More...
 
- Public Attributes inherited from Otter.Graphic
List< TransformationTransforms = new List<Transformation>() { new Transformation() }
 
bool Relative = true
 Determines if the Graphic is rendered relative to its Entity. More...
 
bool Visible = true
 Determines if the Graphic will render. More...
 
float ScrollX = 1
 The scroll factor for the x position. Used for parallax like effects. Values lower than 1 will scroll slower than the camera (appear to be further away) and values higher than 1 will scroll faster than the camera (appear to be closer.) More...
 
float ScrollY = 1
 The scroll factor for the y position. Used for parallax like effects. Values lower than 1 will scroll slower than the camera (appear to be further away) and values higher than 1 will scroll faster than the camera (appear to be closer.) More...
 
float ShakeX
 The horizontal amount to randomly offset the graphic by each frame. More...
 
float ShakeY
 The vertial amount to randomly offset the graphic by each frame. More...
 
Rectangle TextureRegion
 The region to render the Texture with. More...
 
Rectangle AtlasRegion
 The Rectangle to render an AtlasTexture with. More...
 
Shader Shader
 The shader to be applied to this graphic. More...
 
string Name = "Graphic"
 The name of the graphic. More...
 
BlendMode Blend = BlendMode.Alpha
 The blend mode to be applied to this graphic. More...
 
bool RepeatX
 Determines if the image should be rendered multiple times horizontally. More...
 
bool RepeatY
 Determines if the image should be rendered multiple times vertically. More...
 

Properties

int Frames [get, set]
 The total number of frames on the sprite sheet. More...
 
int Columns [get, set]
 The total number of columns on the sprite sheet. More...
 
int Rows [get, set]
 The total number of rows on the spirte sheet. More...
 
TAnimType BufferedAnimation [get, set]
 The current buffered animation. More...
 
bool Active [get, set]
 Determines if the sprite is playing animations. More...
 
bool Paused [get, set]
 Determines if the sprite is advancing its current animation. More...
 
Dictionary< TAnimType, AnimAnims [get, set]
 The dictionary of stored animations. More...
 
TAnimType CurrentAnim [get, set]
 The animation currently playing. More...
 
int CurrentFrame [get, set]
 The current frame of the animation on the sprite sheet. More...
 
int CurrentFrameIndex [get, set]
 The current frame index of the animation, from 0 to frame count - 1. More...
 
Anim this[TAnimType anim] [get]
 
- Properties inherited from Otter.Image
Rectangle ClippingRegion [get, set]
 Defines which area of the Image to show. More...
 
bool FlippedX [get, set]
 Flip the texture coordinates on the X axis. More...
 
bool FlippedY [get, set]
 Flip the texture coordinates on the Y axis. More...
 
Color OutlineColor [get, set]
 The outline color of the Image (only applies to circles and rectangles.) More...
 
float OutlineThickness [get, set]
 The outline thickness of the Image (only applies to circles and rectangles.) More...
 
- Properties inherited from Otter.Graphic
Transformation Transform [get]
 
float X [get, set]
 The X position of the Graphic. More...
 
float Y [get, set]
 The Y position of the Graphic. More...
 
float ScaleX [get, set]
 The horizontal scale of the graphic. Used in the final transformation. More...
 
float ScaleY [get, set]
 The vertical scale of the graphic. Used in the final transformation. More...
 
float Angle [get, set]
 The angle of rotation of the graphic. Used in the final transformation. More...
 
float OriginX [get, set]
 The X origin point to scale and rotate the graphic with. Used in the final transformation. More...
 
float OriginY [get, set]
 The Y origin point to scale and rotate the graphic with. Used in the final transformation. More...
 
Color Color [get, set]
 The base color of the Graphic. Multiplies the vertices of the graphic by this color. More...
 
virtual Texture Texture [get, set]
 The texture that the graphic is using. More...
 
float Alpha [get, set]
 The base transparency of the graphic. A shortcut to access the base color's Alpha. More...
 
int Width [get, set]
 The width of the Graphic. More...
 
int Height [get, set]
 The height of the Graphic. More...
 
float ScaledWidth [get, set]
 The width in pixels of the image after applying the X scale. More...
 
float ScaledHeight [get, set]
 The height in pixels of the image after applying the Y scale. More...
 
virtual bool Smooth [get, set]
 Smooth the texture of a sprite image while scaling it. More...
 
float Scroll [get, set]
 Set both ScrollX and ScrollY. More...
 
float HalfWidth [get]
 Half of the width. More...
 
float HalfHeight [get]
 Half of the height. More...
 
float Scale [set]
 Sets both the ScaleX and ScaleY at the same time. More...
 
bool Repeat [set]
 Sets both RepeatX and RepeatY at the same time. More...
 
float Shake [set]
 A shortcut to set both ShakeX and ShakeY. More...
 
float Left [get]
 The X position of the left side of the Graphic. More...
 
float Top [get]
 The Y position of the top of the Graphic. More...
 
float Right [get]
 The X position of the right side of the Graphic. More...
 
float Bottom [get]
 The Y position of the bottom of the Graphic. More...
 
int TextureLeft [get]
 The X position of the left of the Texture. More...
 
int TextureRight [get]
 The X position of the right of the Texture. More...
 
int TextureTop [get]
 The Y position of the top of the Texture. More...
 
int TextureBottom [get]
 The Y position of the bottom of the Texture. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Otter.Image
static Image CreateRectangle (int width, int height, Color color)
 Creates a rectangle. More...
 
static Image CreateRectangle (Color color)
 Creates a rectangle the size of the active Game window. More...
 
static Image CreateRectangle ()
 Creates a simple black rectangle the size of the active Game window. More...
 
static Image CreateRectangle (int width, int height)
 Creates a rectangle. More...
 
static Image CreateRectangle (int size)
 Creates a rectangle. More...
 
static Image CreateRectangle (int size, Color color)
 Creates a rectangle. More...
 
static Image CreateCircle (int radius, Color color)
 Create a circle. More...
 
static Image CreateCircle (int radius)
 Create a white circle. More...
 
- Static Public Attributes inherited from Otter.Image
static int CirclePointCount = 24
 The amount of points to use when rendering a circle shape. More...
 
- Protected Member Functions inherited from Otter.Image
override void UpdateDrawable ()
 Updates the internal SFML data for rendering. More...
 
- Protected Member Functions inherited from Otter.Graphic
void Append (float x, float y, Color color, float u, float v)
 
void Append (float x, float y, Color color=null)
 
virtual void SFMLRender (Drawable drawable, float x=0, float y=0)
 
- Protected Attributes inherited from Otter.Image
bool flipX = false
 
- Protected Attributes inherited from Otter.Graphic
VertexArray SFMLVertices = new VertexArray(PrimitiveType.Quads)
 
Drawable SFMLDrawable
 
float RepeatSizeX
 
bool roundRendering = true
 
bool Dynamic
 If true the graphic will always update its drawable. More...
 

Detailed Description

Graphic that is used for an animated sprite sheet.

Template Parameters
TAnimType

Constructor & Destructor Documentation

Otter.Spritemap< TAnimType >.Spritemap ( string  source,
int  width,
int  height 
)

Create a new Spritemap from a file path.

Parameters
sourceThe file path to a texture to use for the sprite sheet.
widthThe width of the animation.
heightThe height of the animation.
Otter.Spritemap< TAnimType >.Spritemap ( Texture  texture,
int  width,
int  height 
)

Create a new Spritemap from a Texture.

Parameters
textureThe Texture to use for the sprite sheet.
widthThe width of a cell on the sprite sheet.
heightThe height of a cell on the sprite sheet.
Otter.Spritemap< TAnimType >.Spritemap ( AtlasTexture  texture,
int  width,
int  height 
)

Create a new Spritemap from an AtlasTexture.

Parameters
textureThe AtlasTexture to use for the sprite sheet.
widthThe width of a cell on the sprite sheet.
heightThe height of a cell on the sprite sheet.

Member Function Documentation

void Otter.Spritemap< TAnimType >.Add ( TAnimType  a,
Anim  anim 
)

Add an animation to the list of Anims.

Parameters
aThe key to reference this animation.
animThe anim value.
Anim Otter.Spritemap< TAnimType >.Add ( TAnimType  a,
string  frames,
float  framedelays 
)

Adds an animation using a string for frames and a single value for frame delay.

Parameters
aThe key to store the animation with.
framesThe frames of the animation from the sprite sheet. Example: "0,3,7-11,2,5"
framedelaysThe delay between advancing to the next frame.
Returns
The added animation.
Anim Otter.Spritemap< TAnimType >.Add ( TAnimType  a,
string  frames,
string  framedelays 
)

Add an animation using a string for frames and a string for framedelays.

Parameters
aThe key to store the animation with.
framesThe frames of the animation from the sprite sheet. Example: "0,3,7-11,2,5"
framedelaysThe duration of time to show each frame. Example: "10,10,5,5,50"
Returns
The added animation.
Anim Otter.Spritemap< TAnimType >.Add ( TAnimType  a,
int[]  frames,
float[]  frameDelay = null 
)

Add an animation to the sprite.

Parameters
nameThe name of the animation.
framesAn array of the frames to display.
frameDelayAn array of durations for each frame.
Returns
The added animation.
Anim Otter.Spritemap< TAnimType >.Add ( TAnimType  a,
int[]  frames,
float  framedelays 
)

Adds an animation using an array for frames and a single value for frame delay.

Parameters
aThe key to store the animation with.
framesThe frames of the animation from the sprite sheet. Example: "0,3,7-11,2,5"
framedelaysThe delay between advancing to the next frame.
Returns
The added animation.
Anim Otter.Spritemap< TAnimType >.Anim ( TAnimType  a)

Get the animation with a specific key.

Parameters
aThe key to search with.
Returns
The animation found.
void Otter.Spritemap< TAnimType >.Buffer ( TAnimType  a)

Buffers an animation but does not play it. Call Play() with no arguments to play the buffered animation.

Parameters
aThe animation to buffer.
void Otter.Spritemap< TAnimType >.Clear ( )

Clear the list of animations.

void Otter.Spritemap< TAnimType >.FreezeFrame ( int  frame)

Set the current animation to a specific frame and pause.

Parameters
frameThe frame in terms of the animation.
void Otter.Spritemap< TAnimType >.Pause ( )

Pause the playback of the animation.

void Otter.Spritemap< TAnimType >.Play ( TAnimType  a,
bool  forceReset = true 
)

Play the desired animation.

Parameters
aThe animation to play.
forceResetResets the animation back to the start before playing even if this is the same animation that was already playing.
void Otter.Spritemap< TAnimType >.Play ( bool  forceReset = true)

Plays an animation. If no animation is specified, play the buffered animation.

void Otter.Spritemap< TAnimType >.Reset ( )

Resets the current animation back to the first frame.

void Otter.Spritemap< TAnimType >.Resume ( )

Resume the animation from the current position.

void Otter.Spritemap< TAnimType >.SetFrame ( int  frame)

Set the current animation to a specific frame.

Parameters
frameThe frame in terms of the animation.
void Otter.Spritemap< TAnimType >.SetGlobalFrame ( int  frame)

Set the sprite to a frame on the sprite sheet itself. This will disable the current animation!

Parameters
frameThe global frame in terms of the sprite sheet.
void Otter.Spritemap< TAnimType >.Stop ( )

Stop playback. This will reset the animation to the first frame.

override void Otter.Spritemap< TAnimType >.Update ( )
virtual

Updates the animation. The sprite will not animate without this.

Reimplemented from Otter.Graphic.

Member Data Documentation

float Otter.Spritemap< TAnimType >.Speed = 1f

The playback speed of all animations.

Property Documentation

bool Otter.Spritemap< TAnimType >.Active
getset

Determines if the sprite is playing animations.

Dictionary<TAnimType, Anim> Otter.Spritemap< TAnimType >.Anims
getset

The dictionary of stored animations.

TAnimType Otter.Spritemap< TAnimType >.BufferedAnimation
getset

The current buffered animation.

int Otter.Spritemap< TAnimType >.Columns
getset

The total number of columns on the sprite sheet.

TAnimType Otter.Spritemap< TAnimType >.CurrentAnim
getset

The animation currently playing.

int Otter.Spritemap< TAnimType >.CurrentFrame
getset

The current frame of the animation on the sprite sheet.

int Otter.Spritemap< TAnimType >.CurrentFrameIndex
getset

The current frame index of the animation, from 0 to frame count - 1.

int Otter.Spritemap< TAnimType >.Frames
getset

The total number of frames on the sprite sheet.

bool Otter.Spritemap< TAnimType >.Paused
getset

Determines if the sprite is advancing its current animation.

int Otter.Spritemap< TAnimType >.Rows
getset

The total number of rows on the spirte sheet.


The documentation for this class was generated from the following file: