33
33
#define INCLUDE_RAYLIB_ASEPRITE_H_
34
34
35
35
#include "raylib.h" // NOLINT
36
- #include "./cute_aseprite.h" // NOLINT
37
36
38
37
#ifdef __cplusplus
39
38
extern "C" {
40
39
#endif
41
40
42
- /**
43
- * The loaded Aseprite data.
44
- *
45
- * @see LoadAseprite()
46
- * @see UnloadAseprite()
47
- */
48
- typedef struct Aseprite {
49
- ase_t * ase ; // Pointer to the cute_aseprite data.
50
- } Aseprite ;
51
-
52
- /**
53
- * Tag information from Aseprite.
54
- *
55
- * @see LoadAsepriteTag()
56
- * @see LoadAsepriteTagFromIndex()
57
- */
58
- typedef struct AsepriteTag {
59
- char * name ; // The name of the tag.
60
- int currentFrame ; // The frame that the tag is currently on
61
- float timer ; // The countdown timer in seconds
62
- int direction ; // Whether we are moving forwards, or backwards through the frames
63
- float speed ; // The animation speed factor (1 is normal speed, 2 is double speed)
64
- Color color ; // The color provided for the tag
65
- bool loop ; // Whether to continue to play the animation when the animation finishes
66
- bool paused ; // Set to true to not progression of the animation
67
- Aseprite aseprite ; // The loaded Aseprite file
68
- ase_tag_t * tag ; // The active tag to act upon
69
- } AsepriteTag ;
41
+ typedef struct Aseprite Aseprite ; // A loaded Aseprite file
42
+ typedef struct AsepriteTag AsepriteTag ; // A tag sprite animation within an Aseprite file
70
43
71
44
// Aseprite functions
72
45
Aseprite LoadAseprite (const char * fileName ); // Load an .aseprite file
@@ -108,6 +81,10 @@ void DrawAsepriteTagPro(AsepriteTag tag, Rectangle dest, Vector2 origin, float r
108
81
#define CUTE_ASEPRITE_IMPLEMENTATION
109
82
#endif
110
83
84
+ #ifdef __cplusplus
85
+ extern "C" {
86
+ #endif
87
+
111
88
// Have cute_aseprite report warnings through raylib.
112
89
#define CUTE_ASEPRITE_WARNING (msg ) TraceLog(LOG_WARNING, "ASEPRITE: %s (cute_headers.h:%i)", msg, __LINE__)
113
90
@@ -154,9 +131,34 @@ void raylib_aseprite_fclose(CUTE_ASEPRITE_FILE* fp) {
154
131
155
132
#include "cute_aseprite.h" // NOLINT
156
133
157
- #ifdef __cplusplus
158
- extern "C" {
159
- #endif
134
+ /**
135
+ * The loaded Aseprite data.
136
+ *
137
+ * @see LoadAseprite()
138
+ * @see UnloadAseprite()
139
+ */
140
+ struct Aseprite {
141
+ ase_t * ase ; // Pointer to the cute_aseprite data.
142
+ };
143
+
144
+ /**
145
+ * Tag information from Aseprite.
146
+ *
147
+ * @see LoadAsepriteTag()
148
+ * @see LoadAsepriteTagFromIndex()
149
+ */
150
+ struct AsepriteTag {
151
+ char * name ; // The name of the tag.
152
+ int currentFrame ; // The frame that the tag is currently on
153
+ float timer ; // The countdown timer in seconds
154
+ int direction ; // Whether we are moving forwards, or backwards through the frames
155
+ float speed ; // The animation speed factor (1 is normal speed, 2 is double speed)
156
+ Color color ; // The color provided for the tag
157
+ bool loop ; // Whether to continue to play the animation when the animation finishes
158
+ bool paused ; // Set to true to not progression of the animation
159
+ Aseprite aseprite ; // The loaded Aseprite file
160
+ ase_tag_t * tag ; // The active tag to act upon
161
+ };
160
162
161
163
/**
162
164
* Load an .aseprite file through its memory data.
@@ -468,24 +470,22 @@ void UpdateAsepriteTag(AsepriteTag* tag) {
468
470
// Advance the frame and see if it's time to reset the position.
469
471
tag -> currentFrame += tag -> direction ;
470
472
switch (aseTag -> loop_animation_direction ) {
471
- case ASE_ANIMATION_DIRECTION_BACKWORDS :
472
- if (tag -> currentFrame < aseTag -> from_frame ) {
473
+ case ASE_ANIMATION_DIRECTION_FORWARDS :
474
+ if (tag -> currentFrame > aseTag -> to_frame ) {
473
475
if (tag -> loop ) {
474
- tag -> currentFrame = aseTag -> to_frame ;
475
- }
476
- else {
477
476
tag -> currentFrame = aseTag -> from_frame ;
477
+ } else {
478
+ tag -> currentFrame = aseTag -> to_frame ;
478
479
tag -> paused = true;
479
480
}
480
481
}
481
482
break ;
482
- case ASE_ANIMATION_DIRECTION_FORWARDS :
483
- if (tag -> currentFrame > aseTag -> to_frame ) {
483
+ case ASE_ANIMATION_DIRECTION_BACKWORDS :
484
+ if (tag -> currentFrame < aseTag -> from_frame ) {
484
485
if (tag -> loop ) {
485
- tag -> currentFrame = aseTag -> from_frame ;
486
- }
487
- else {
488
486
tag -> currentFrame = aseTag -> to_frame ;
487
+ } else {
488
+ tag -> currentFrame = aseTag -> from_frame ;
489
489
tag -> paused = true;
490
490
}
491
491
}
@@ -496,20 +496,17 @@ void UpdateAsepriteTag(AsepriteTag* tag) {
496
496
tag -> direction = -1 ;
497
497
if (tag -> loop ) {
498
498
tag -> currentFrame = aseTag -> to_frame - 1 ;
499
- }
500
- else {
499
+ } else {
501
500
tag -> currentFrame = aseTag -> to_frame ;
502
501
tag -> paused = true;
503
502
}
504
503
}
505
- }
506
- else {
504
+ } else {
507
505
if (tag -> currentFrame < aseTag -> from_frame ) {
508
506
tag -> direction = 1 ;
509
507
if (tag -> loop ) {
510
508
tag -> currentFrame = aseTag -> from_frame + 1 ;
511
- }
512
- else {
509
+ } else {
513
510
tag -> currentFrame = aseTag -> from_frame ;
514
511
tag -> paused = true;
515
512
}
0 commit comments