mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 18:56:54 +08:00
Per attachment color.
This commit is contained in:
parent
55c98fc7f1
commit
cf9a3a4109
@ -38,7 +38,7 @@ extern "C" {
|
|||||||
struct spSlot;
|
struct spSlot;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ATTACHMENT_REGION, ATTACHMENT_REGION_SEQUENCE, ATTACHMENT_BOUNDING_BOX
|
ATTACHMENT_REGION, ATTACHMENT_BOUNDING_BOX
|
||||||
} spAttachmentType;
|
} spAttachmentType;
|
||||||
|
|
||||||
typedef struct spAttachment spAttachment;
|
typedef struct spAttachment spAttachment;
|
||||||
|
|||||||
@ -47,6 +47,7 @@ typedef struct spRegionAttachment spRegionAttachment;
|
|||||||
struct spRegionAttachment {
|
struct spRegionAttachment {
|
||||||
spAttachment super;
|
spAttachment super;
|
||||||
float x, y, scaleX, scaleY, rotation, width, height;
|
float x, y, scaleX, scaleY, rotation, width, height;
|
||||||
|
float r, g, b, a;
|
||||||
|
|
||||||
void* rendererObject;
|
void* rendererObject;
|
||||||
int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */
|
int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */
|
||||||
|
|||||||
@ -43,6 +43,10 @@ spRegionAttachment* spRegionAttachment_create (const char* name) {
|
|||||||
spRegionAttachment* self = NEW(spRegionAttachment);
|
spRegionAttachment* self = NEW(spRegionAttachment);
|
||||||
self->scaleX = 1;
|
self->scaleX = 1;
|
||||||
self->scaleY = 1;
|
self->scaleY = 1;
|
||||||
|
self->r = 1;
|
||||||
|
self->g = 1;
|
||||||
|
self->b = 1;
|
||||||
|
self->a = 1;
|
||||||
_spAttachment_init(SUPER(self), name, ATTACHMENT_REGION, _spRegionAttachment_dispose);
|
_spAttachment_init(SUPER(self), name, ATTACHMENT_REGION, _spRegionAttachment_dispose);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -414,6 +414,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
spAttachment* attachment;
|
spAttachment* attachment;
|
||||||
const char* skinAttachmentName = attachmentMap->name;
|
const char* skinAttachmentName = attachmentMap->name;
|
||||||
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
|
||||||
|
const char* color;
|
||||||
|
|
||||||
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
||||||
spAttachmentType type;
|
spAttachmentType type;
|
||||||
@ -421,8 +422,6 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
type = ATTACHMENT_REGION;
|
type = ATTACHMENT_REGION;
|
||||||
else if (strcmp(typeString, "boundingbox") == 0)
|
else if (strcmp(typeString, "boundingbox") == 0)
|
||||||
type = ATTACHMENT_BOUNDING_BOX;
|
type = ATTACHMENT_BOUNDING_BOX;
|
||||||
else if (strcmp(typeString, "regionsequence") == 0)
|
|
||||||
type = ATTACHMENT_REGION_SEQUENCE;
|
|
||||||
else {
|
else {
|
||||||
spSkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
_spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
_spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
||||||
@ -440,8 +439,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (attachment->type) {
|
switch (attachment->type) {
|
||||||
case ATTACHMENT_REGION:
|
case ATTACHMENT_REGION: {
|
||||||
case ATTACHMENT_REGION_SEQUENCE: {
|
|
||||||
spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment;
|
spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment;
|
||||||
regionAttachment->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
regionAttachment->x = Json_getFloat(attachmentMap, "x", 0) * self->scale;
|
||||||
regionAttachment->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
regionAttachment->y = Json_getFloat(attachmentMap, "y", 0) * self->scale;
|
||||||
@ -450,6 +448,15 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
regionAttachment->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
regionAttachment->rotation = Json_getFloat(attachmentMap, "rotation", 0);
|
||||||
regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
||||||
regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale;
|
||||||
|
|
||||||
|
color = Json_getString(slotMap, "color", 0);
|
||||||
|
if (color) {
|
||||||
|
regionAttachment->r = toColor(color, 0);
|
||||||
|
regionAttachment->g = toColor(color, 1);
|
||||||
|
regionAttachment->b = toColor(color, 2);
|
||||||
|
regionAttachment->a = toColor(color, 3);
|
||||||
|
}
|
||||||
|
|
||||||
spRegionAttachment_updateOffset(regionAttachment);
|
spRegionAttachment_updateOffset(regionAttachment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user