nomlib
Loading...
Searching...
No Matches
nom::SpriteSheet Class Reference

Container class for deserialized sprite sheet data. More...

#include <SpriteSheet.hpp>

Public Types

typedef SpriteSheet self_type

Public Member Functions

 SpriteSheet ()
 ~SpriteSheet ()
 Destructor.
SpriteSheetclone () const
 Make a duplicate of this object's instance.
const IntRect & dimensions (int index) const
 Get the calculations made for a particular ID number.
int frames () const
 Obtain the number of frames this object contains.
bool empty () const
 Obtain whether the sprite sheet is empty or not.
std::string version () const
 Get the current version of the sprite sheet file format.
const std::string & sheet_filename () const
 Get the sprite sheet's filename.
int sheet_width () const
 Get the total sprite sheet width.
int sheet_height () const
 Get the total sprite sheet height.
int sheet_padding () const
 Get the sprite sheet's padding.
int sheet_spacing () const
 Get the sprite sheet's spacing.
int total_frames () const
 Get the total number of sprite frames.
bool load_file (const std::string &filename)
 De-serialize an existing JSON file.
bool load_sheet_object (const Value &object)
 Load a sprite sheet from a de-serialized object.
bool insert_frame (nom::size_type frame_num, const IntRect &frame_bounds)
bool append_frame (const IntRect &frame_bounds)
bool remove_frame (nom::size_type frame)
 Erase an existing frame from the sheet.
void remove_frames ()
 Destroy all stored sprite frames.
void dump () const
 Dump the state of this object instance.

Static Public Attributes

static const VersionInfo VERSION

Private Attributes

std::map< int, IntRect > sheet_
 Sprite sheet container.
std::string sheet_filename_
 Source filename used is saved with the output (meta-data).
int sheet_spacing_
 Source spacing used is saved with the output (meta-data).
int sheet_padding_
 Source padding used is saved with the output (meta-data).
int sheet_width_
 Source sheet_width used is saved with the output (meta-data).
int sheet_height_
 Source sheet_height used is saved with the output (meta-data).
int total_frames_
 The total number of sprite frames; as per the number of objects in the frames object node.

Detailed Description

Container class for deserialized sprite sheet data.

TexturePacker with a custom exporter for nomlib is used for saving sprite frame data. See Resources/SharedSupport/TexturePacker for the custom exporter used.

Definition at line 46 of file SpriteSheet.hpp.

Member Typedef Documentation

◆ self_type

typedef SpriteSheet nom::SpriteSheet::self_type

Definition at line 51 of file SpriteSheet.hpp.

Constructor & Destructor Documentation

◆ SpriteSheet()

nom::SpriteSheet::SpriteSheet ( )

Default construct for initializing instance variables to their respective defaults.

Member Function Documentation

◆ load_file()

bool nom::SpriteSheet::load_file ( const std::string & filename)

De-serialize an existing JSON file.

Parameters
filenameThe absolute file path to the JSON input.
Returns
An object filled with complete data from a file on success, or a non-modified object upon failure.
Todo
Rename to load_sheet_file?

◆ load_sheet_object()

bool nom::SpriteSheet::load_sheet_object ( const Value & object)

Load a sprite sheet from a de-serialized object.

Parameters
objectAn existing, de-serialized object to use.

◆ sheet_filename()

const std::string & nom::SpriteSheet::sheet_filename ( ) const

Get the sprite sheet's filename.

Remarks
This data corresponds to the meta-data object node's 'filename' value.

◆ sheet_height()

int nom::SpriteSheet::sheet_height ( ) const

Get the total sprite sheet height.

Remarks
This data corresponds to the meta-data object node's 'height' value.

◆ sheet_padding()

int nom::SpriteSheet::sheet_padding ( ) const

Get the sprite sheet's padding.

Remarks
This data corresponds to the meta-data object node's 'padding' value.

◆ sheet_spacing()

int nom::SpriteSheet::sheet_spacing ( ) const

Get the sprite sheet's spacing.

Remarks
This data corresponds to the meta-data object node's 'spacing' value.

◆ sheet_width()

int nom::SpriteSheet::sheet_width ( ) const

Get the total sprite sheet width.

Remarks
This data corresponds to the meta-data object node's 'width' value.

◆ total_frames()

int nom::SpriteSheet::total_frames ( ) const

Get the total number of sprite frames.

Remarks
This data corresponds to the meta-data object node's 'total_frames' value.

Member Data Documentation

◆ sheet_

std::map<int, IntRect> nom::SpriteSheet::sheet_
private

Sprite sheet container.

Remarks
The key field of this container (an int) represents the frame's identifier, whereas its second field represents the frame's data.

Definition at line 143 of file SpriteSheet.hpp.

◆ sheet_filename_

std::string nom::SpriteSheet::sheet_filename_
private

Source filename used is saved with the output (meta-data).

Definition at line 146 of file SpriteSheet.hpp.

◆ sheet_height_

int nom::SpriteSheet::sheet_height_
private

Source sheet_height used is saved with the output (meta-data).

Definition at line 158 of file SpriteSheet.hpp.

◆ sheet_padding_

int nom::SpriteSheet::sheet_padding_
private

Source padding used is saved with the output (meta-data).

Definition at line 152 of file SpriteSheet.hpp.

◆ sheet_spacing_

int nom::SpriteSheet::sheet_spacing_
private

Source spacing used is saved with the output (meta-data).

Definition at line 149 of file SpriteSheet.hpp.

◆ sheet_width_

int nom::SpriteSheet::sheet_width_
private

Source sheet_width used is saved with the output (meta-data).

Definition at line 155 of file SpriteSheet.hpp.

◆ total_frames_

int nom::SpriteSheet::total_frames_
private

The total number of sprite frames; as per the number of objects in the frames object node.

Definition at line 162 of file SpriteSheet.hpp.

◆ VERSION

const VersionInfo nom::SpriteSheet::VERSION
static

Definition at line 49 of file SpriteSheet.hpp.


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