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

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

#include <SpriteSheet.hpp>

Inheritance diagram for nom::SpriteSheet:
[legend]

Public Types

typedef SpriteSheet self_type
Public Types inherited from nom::IObject
typedef IObject self_type
typedef IObject * raw_ptr

Public Member Functions

 SpriteSheet ()
 ~SpriteSheet ()
 Destructor.
SpriteSheet * clone () 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.
Public Member Functions inherited from nom::IObject
 IObject (void)
 Default constructor.
virtual ~IObject (void)
 Virtual destructor.
virtual ObjectTypeInfo type (void) const
 Obtain the object's class type.
virtual bool is_type (const ObjectTypeInfo &rhs) const
 Compare this object type with another object's type.

Static Public Attributes

static NOM_EXPORT const VersionInfo VERSION
Static Public Attributes inherited from nom::IObject
static uint64 total_alloc_bytes
static uint64 total_dealloc_bytes

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.

Additional Inherited Members

Static Public Member Functions inherited from nom::IObject
template<typename Base, typename Derived>
static bool is_a (const Derived object)
 Compare two objects to determine if a derived class inherits from a base class object.
static void * operator new (nom::size_type mem)
static void operator delete (void *ptr)

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 50 of file SpriteSheet.hpp.

Member Typedef Documentation

◆ self_type

typedef SpriteSheet nom::SpriteSheet::self_type

Definition at line 55 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 147 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 150 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 162 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 156 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 153 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 159 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 166 of file SpriteSheet.hpp.

◆ VERSION

NOM_EXPORT const VersionInfo nom::SpriteSheet::VERSION
static

Definition at line 53 of file SpriteSheet.hpp.


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