SpriteEditor
Public Member Functions | Public Attributes | List of all members
Sprite Class Reference

Sprite class to preview the constructed Sprite. More...

#include <Sprite.hpp>

Public Member Functions

 Sprite ()
 Constructor, does nothing.
 
 ~Sprite ()
 Destructor, does nothing.
 
void destroy ()
 Free all the resources allocated.
 
int init (std::string filePath, int width, int height, std::string frames, SDL_Renderer *renderer, TTF_Font *font)
 Initialize the object with all the parameters. More...
 
int loadFile (std::string filePath, SDL_Renderer *renderer, TTF_Font *font)
 Load the sprite from previous saved file. More...
 
int saveFile (std::string filePath)
 Save the sprite into file with specific format. More...
 
void render (int x, int y, SDL_Renderer *renderer)
 Render the sprite. More...
 

Public Attributes

bool load
 Whether currently there's a sprite loaded.
 

Detailed Description

Sprite class to preview the constructed Sprite.

Windows and Mac use a different path If you have compilation errors, change this as needed.

Member Function Documentation

◆ init()

int Sprite::init ( std::string  filePath,
int  width,
int  height,
std::string  frames,
SDL_Renderer *  renderer,
TTF_Font *  font 
)

Initialize the object with all the parameters.

Frame input is just a number.

Frame input is separated by comma.

Cheat split function.

If there are more than 40 frames, only show 40 and show this message.

◆ loadFile()

int Sprite::loadFile ( std::string  filePath,
SDL_Renderer *  renderer,
TTF_Font *  font 
)

Load the sprite from previous saved file.

After reading all the text, still use the init function.

◆ render()

void Sprite::render ( int  x,
int  y,
SDL_Renderer *  renderer 
)

Render the sprite.

Render the arbitrary frames.

Draw the animated sprite.

If there's more than 40 frames, show the message to tell user that.

◆ saveFile()

int Sprite::saveFile ( std::string  filePath)

Save the sprite into file with specific format.

Can only save the sprite into file with specific suffix.


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