diff --git a/spine-c/.cproject b/spine-c/.cproject index 6e4ecd681..b8e4a0253 100644 --- a/spine-c/.cproject +++ b/spine-c/.cproject @@ -53,6 +53,7 @@ + diff --git a/spine-c/src/main.c b/spine-c/example/main.c similarity index 92% rename from spine-c/src/main.c rename to spine-c/example/main.c index 80c8ec866..b71cb2b92 100644 --- a/spine-c/src/main.c +++ b/spine-c/example/main.c @@ -35,32 +35,6 @@ AtlasPage* AtlasPage_create (const char* name) { /**/ -typedef struct { - RegionAttachment super; - int extraData; -} ExampleRegionAttachment; - -void _ExampleRegionAttachment_dispose (Attachment* attachment) { - ExampleRegionAttachment* self = (ExampleRegionAttachment*)attachment; - _RegionAttachment_deinit(&self->super); - - self->extraData = 0; - - FREE(self) -} - -RegionAttachment* RegionAttachment_create (const char* name, AtlasRegion* region) { - ExampleRegionAttachment* self = CALLOC(ExampleRegionAttachment, 1) - _RegionAttachment_init(&self->super, name); - self->super.super._dispose = _ExampleRegionAttachment_dispose; - - self->extraData = 456; - - return &self->super; -} - -/**/ - typedef struct { Skeleton super; int extraData; @@ -87,6 +61,38 @@ Skeleton* Skeleton_create (SkeletonData* data) { /**/ +typedef struct { + RegionAttachment super; + int extraData; +} ExampleRegionAttachment; + +void _ExampleRegionAttachment_dispose (Attachment* attachment) { + ExampleRegionAttachment* self = (ExampleRegionAttachment*)attachment; + _RegionAttachment_deinit(&self->super); + + self->extraData = 0; + + FREE(self) +} + +void _ExampleRegionAttachment_draw (Attachment* attachment, Slot* slot) { + ExampleRegionAttachment* self = (ExampleRegionAttachment*)attachment; + // Draw or queue region for drawing. +} + +RegionAttachment* RegionAttachment_create (const char* name, AtlasRegion* region) { + ExampleRegionAttachment* self = CALLOC(ExampleRegionAttachment, 1) + _RegionAttachment_init(&self->super, name); + self->super.super._dispose = _ExampleRegionAttachment_dispose; + self->super.super._draw = _ExampleRegionAttachment_draw; + + self->extraData = 456; + + return &self->super; +} + +/**/ + int main (void) { Atlas* atlas = Atlas_readAtlasFile("data/spineboy.atlas"); printf("First region name: %s, x: %d, y: %d\n", atlas->regions->name, atlas->regions->x, atlas->regions->y); diff --git a/spine-sfml/src/spine/spine-sfml.cpp b/spine-sfml/src/spine/spine-sfml.cpp index dc102b134..4cb252b14 100644 --- a/spine-sfml/src/spine/spine-sfml.cpp +++ b/spine-sfml/src/spine/spine-sfml.cpp @@ -21,7 +21,9 @@ namespace spine { void _SfmlAtlasPage_dispose (AtlasPage* page) { SfmlAtlasPage* self = (SfmlAtlasPage*)page; _AtlasPage_deinit(&self->super); + delete self->texture; + FREE(page) }