mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 09:46:02 +08:00
Better spine-c example.
This commit is contained in:
parent
6765ec4235
commit
1be279e4e8
@ -53,6 +53,7 @@
|
|||||||
</toolChain>
|
</toolChain>
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="example"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -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 {
|
typedef struct {
|
||||||
Skeleton super;
|
Skeleton super;
|
||||||
int extraData;
|
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) {
|
int main (void) {
|
||||||
Atlas* atlas = Atlas_readAtlasFile("data/spineboy.atlas");
|
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);
|
printf("First region name: %s, x: %d, y: %d\n", atlas->regions->name, atlas->regions->x, atlas->regions->y);
|
||||||
@ -21,7 +21,9 @@ namespace spine {
|
|||||||
void _SfmlAtlasPage_dispose (AtlasPage* page) {
|
void _SfmlAtlasPage_dispose (AtlasPage* page) {
|
||||||
SfmlAtlasPage* self = (SfmlAtlasPage*)page;
|
SfmlAtlasPage* self = (SfmlAtlasPage*)page;
|
||||||
_AtlasPage_deinit(&self->super);
|
_AtlasPage_deinit(&self->super);
|
||||||
|
|
||||||
delete self->texture;
|
delete self->texture;
|
||||||
|
|
||||||
FREE(page)
|
FREE(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user