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