Sprite atlases

Defines

BINOCLE_MAX_ATLAS_FILENAME_LENGTH

Typedefs

typedef enum binocle_atlas_file_format binocle_atlas_file_format

The format of the atlas. We currently support libGDX and TexturePacker

typedef struct binocle_atlas_animation binocle_atlas_animation
typedef struct binocle_atlas_slice_key binocle_atlas_slice_key
typedef struct binocle_atlas_slice binocle_atlas_slice
typedef struct binocle_atlas_tp_meta binocle_atlas_tp_meta
typedef struct binocle_atlas_tp_frame binocle_atlas_tp_frame
typedef struct binocle_atlas_texturepacker binocle_atlas_texturepacker
typedef struct binocle_atlas_texturepacker_load_desc binocle_atlas_texturepacker_load_desc

Enums

enum binocle_atlas_file_format

The format of the atlas. We currently support libGDX and TexturePacker

Values:

enumerator BINOCLE_ATLAS_FILE_FORMAT_TEXTUREPACKER
enumerator BINOCLE_ATLAS_FILE_FORMAT_LIBGDX

Functions

bool binocle_atlas_load_texturepacker(binocle_atlas_texturepacker *atlas, binocle_atlas_texturepacker_load_desc *desc)

Load a TexturePacker JSON atlas into the atlas struct.

Parameters:
Returns:

true if successful, false otherwise

void binocle_atlas_texturepacker_create_subtextures(binocle_atlas_texturepacker *atlas, struct sg_image *texture, struct binocle_subtexture *subtextures, int *num_subtextures)

Creates the subtexttures from the frames of an already loaded TexturePacker JSON atlas.

Parameters:
  • atlas – an instance of binocle_atlas_texturepacker with the data of the atlas

  • texture – the corresponding texture associated to this atlas. It has to be already loaded.

  • subtextures – an array of subtextures to store those coming from the JSON

  • num_subtextures – the number of subtextures that have been loaded by this function

void binocle_atlas_destroy_texturepacker(binocle_atlas_texturepacker *atlas)

Frees the resources of the atlas

Parameters:

atlas – an instance of binocle_atlas_texturepacker to release

void binocle_atlas_load_libgdx(char *filename, struct sg_image *texture, struct binocle_subtexture *subtextures, int *num_subtextures)

Load a libGDX atlas

Note

Not yet implemented

Parameters:
  • filename – the JSON file path and name

  • texture – the corresponding texture that we already loaded

  • subtextures – an array of subtextures to store those coming from the JSON

  • num_subtextures – the number of subtextures that have been loaded by this function

void binocle_atlas_animation_destroy(binocle_atlas_animation *animations, size_t num_animations)

Frees the memory allocated while loading animations

Parameters:
  • animations – a pointer to the binocle_atlas_animation struct to free

  • num_animations – the number of animations previously loaded

void binocle_atlas_texturepacker_create_animations(binocle_atlas_texturepacker *atlas, struct sg_image texture, struct binocle_sprite *sprite)

Creates the animations in a given sprite based on the content of the atlas

Parameters:
  • atlas – the TexturePacker atlas

  • texture – the texture with the image of the atlas

  • sprite – the sprite instance whose animations have to be created

struct binocle_atlas_animation

Public Members

const char *name
const char *direction
int from
int to
bool repeat
struct binocle_atlas_slice_key

Public Members

int frame
kmAABB2 bounds
kmVec2 pivot
struct binocle_atlas_slice

Public Members

const char *name
const char *color
binocle_atlas_slice_key *keys
size_t num_keys
struct binocle_atlas_tp_meta

Public Members

char *app
char *version
char *image
char *format
char *scale
char *smartupdate
kmVec2 size
binocle_atlas_animation *frame_tags
size_t num_frame_tags
binocle_atlas_slice *slices
size_t num_slices
struct binocle_atlas_tp_frame

Public Members

char *filename
kmAABB2 frame
bool rotated
bool trimmed
kmAABB2 sprite_source_size
kmVec2 source_size
kmVec2 pivot
int duration
struct binocle_atlas_texturepacker

Public Members

char asset_filename[BINOCLE_MAX_ATLAS_FILENAME_LENGTH]
binocle_atlas_tp_frame *frames
size_t num_frames
binocle_atlas_tp_meta meta
struct binocle_atlas_texturepacker_load_desc

Public Members

const char *filename

the JSON file path and name

binocle_fs_supported fs