# Khaotic Engine Reborn: sprite_class Class Reference

Loading...
Searching...
No Matches
sprite_class Class Reference

## Public Member Functions

| sprite_class (const sprite_class &)
bool | Initialize (ID3D11Device *, ID3D11DeviceContext *, int, int, char *, int, int)
void | Shutdown ()
bool | Render (ID3D11DeviceContext *)
void | Update (float)
int | GetIndexCount ()
ID3D11ShaderResourceView * | GetTexture ()
void | SetRenderLocation (int, int)

## Detailed Description

Definition at line 22 of file sprite_class.h.

## Constructor & Destructor Documentation

## sprite_class() [1/2]

sprite_class::sprite_class | ( |  | ) |

Definition at line 4 of file sprite_class.cpp.

{
m_vertexBuffer = 0;
m_indexBuffer = 0;
m_Textures = 0;
}

## sprite_class() [2/2]

sprite_class::sprite_class | ( | const sprite_class & | other | ) |

Definition at line 12 of file sprite_class.cpp.

{
}

## ~sprite_class()

sprite_class::~sprite_class | ( |  | ) |

Definition at line 17 of file sprite_class.cpp.

{
}

## Member Function Documentation

## GetIndexCount()

int sprite_class::GetIndexCount | ( |  | ) |

Definition at line 109 of file sprite_class.cpp.

{
return m_indexCount;
}

## GetTexture()

ID3D11ShaderResourceView * sprite_class::GetTexture | ( |  | ) |

Definition at line 114 of file sprite_class.cpp.

{
return m_Textures[m_currentTexture].GetTexture();
}

## Initialize()

bool sprite_class::Initialize | ( | ID3D11Device * | device,
|  | ID3D11DeviceContext * | deviceContext,
|  | int | screenWidth,
|  | int | screenHeight,
|  | char * | spriteFilename,
|  | int | renderX,
|  | int | renderY )

Definition at line 21 of file sprite_class.cpp.

{
bool result;
// Store the screen size.
m_screenWidth = screenWidth;
m_screenHeight = screenHeight;
// Store where the sprite should be rendered to.
m_renderX = renderX;
m_renderY = renderY;
// Initialize the frame time for this sprite object.
m_frameTime = 0;
// Initialize the vertex and index buffer that hold the geometry for the sprite bitmap.
result = InitializeBuffers(device);
if (!result)
{
return false;
}
// Load the textures for this sprite.
result = LoadTextures(device, deviceContext, spriteFilename);
if (!result)
{
return false;
}
return true;
}

## Render()

bool sprite_class::Render | ( | ID3D11DeviceContext * | deviceContext | ) |

Definition at line 67 of file sprite_class.cpp.

{
bool result;
// Update the buffers if the position of the sprite has changed from its original position.
result = UpdateBuffers(deviceContext);
if (!result)
{
return false;
}
// Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
RenderBuffers(deviceContext);
return true;
}

## SetRenderLocation()

void sprite_class::SetRenderLocation | ( | int | x,
|  | int | y )

Definition at line 416 of file sprite_class.cpp.

{
m_renderX = x;
m_renderY = y;
return;
}

## Shutdown()

void sprite_class::Shutdown | ( |  | ) |

Definition at line 55 of file sprite_class.cpp.

{
// Release the textures used for this sprite.
ReleaseTextures();
// Release the vertex and index buffers.
ShutdownBuffers();
return;
}

## Update()

void sprite_class::Update | ( | float | frameTime | ) |

Definition at line 85 of file sprite_class.cpp.

{
// Increment the frame time each frame.
m_frameTime += frameTime;
// Check if the frame time has reached the cycle time.
if (m_frameTime >= m_cycleTime)
{
// If it has then reset the frame time and cycle to the next sprite in the texture array.
m_frameTime -= m_cycleTime;
m_currentTexture++;
// If we are at the last sprite texture then go back to the beginning of the texture array to the first texture again.
if (m_currentTexture == m_textureCount)
{
m_currentTexture = 0;
}
}
return;
}

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

- enginecustom/src/inc/system/sprite_class.h
- enginecustom/src/src/system/sprite_class.cpp