Fixed fo C++, really this time.

Fixed iOS project.
This commit is contained in:
NathanSweet 2013-04-06 17:57:45 +02:00
parent fa53aad63f
commit 8b8896bbeb
5 changed files with 37 additions and 31 deletions

View File

@ -25,7 +25,7 @@
[self addChild:skeletonNode];
[self scheduleUpdate];
return self;
}

View File

@ -27,8 +27,7 @@
43C32864170B0C6C004A9460 /* Skin.c in Sources */ = {isa = PBXBuildFile; fileRef = 43C3284E170B0C6C004A9460 /* Skin.c */; };
43C32865170B0C6C004A9460 /* Slot.c in Sources */ = {isa = PBXBuildFile; fileRef = 43C32850170B0C6C004A9460 /* Slot.c */; };
43C32866170B0C6C004A9460 /* SlotData.c in Sources */ = {isa = PBXBuildFile; fileRef = 43C32852170B0C6C004A9460 /* SlotData.c */; };
43C3286C170B0DA6004A9460 /* spineboy-skeleton.json in Resources */ = {isa = PBXBuildFile; fileRef = 43C32868170B0DA6004A9460 /* spineboy-skeleton.json */; };
43C3286D170B0DA6004A9460 /* spineboy-walk.json in Resources */ = {isa = PBXBuildFile; fileRef = 43C32869170B0DA6004A9460 /* spineboy-walk.json */; };
43C3286C170B0DA6004A9460 /* spineboy.json in Resources */ = {isa = PBXBuildFile; fileRef = 43C32868170B0DA6004A9460 /* spineboy.json */; };
43C3286E170B0DA6004A9460 /* spineboy.atlas in Resources */ = {isa = PBXBuildFile; fileRef = 43C3286A170B0DA6004A9460 /* spineboy.atlas */; };
43C3286F170B0DA6004A9460 /* spineboy.png in Resources */ = {isa = PBXBuildFile; fileRef = 43C3286B170B0DA6004A9460 /* spineboy.png */; };
43C3287D170B0DBE004A9460 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 43C32871170B0DBE004A9460 /* Default-568h@2x.png */; };
@ -213,8 +212,7 @@
43C32852170B0C6C004A9460 /* SlotData.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SlotData.c; path = "../spine-c/src/spine/SlotData.c"; sourceTree = "<group>"; };
43C32853170B0C6C004A9460 /* SlotData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SlotData.h; path = "../spine-c/include/spine/SlotData.h"; sourceTree = "<group>"; };
43C32854170B0C6C004A9460 /* spine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = spine.h; path = "../spine-c/include/spine/spine.h"; sourceTree = "<group>"; };
43C32868170B0DA6004A9460 /* spineboy-skeleton.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "spineboy-skeleton.json"; path = "Resources/spineboy-skeleton.json"; sourceTree = "<group>"; };
43C32869170B0DA6004A9460 /* spineboy-walk.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "spineboy-walk.json"; path = "Resources/spineboy-walk.json"; sourceTree = "<group>"; };
43C32868170B0DA6004A9460 /* spineboy.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = spineboy.json; path = Resources/spineboy.json; sourceTree = "<group>"; };
43C3286A170B0DA6004A9460 /* spineboy.atlas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = spineboy.atlas; path = Resources/spineboy.atlas; sourceTree = "<group>"; };
43C3286B170B0DA6004A9460 /* spineboy.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spineboy.png; path = Resources/spineboy.png; sourceTree = "<group>"; };
43C32871170B0DBE004A9460 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "Resources-ios/Default-568h@2x.png"; sourceTree = "<group>"; };
@ -587,8 +585,7 @@
43C32867170B0C7F004A9460 /* Resources */ = {
isa = PBXGroup;
children = (
43C32868170B0DA6004A9460 /* spineboy-skeleton.json */,
43C32869170B0DA6004A9460 /* spineboy-walk.json */,
43C32868170B0DA6004A9460 /* spineboy.json */,
43C3286A170B0DA6004A9460 /* spineboy.atlas */,
43C3286B170B0DA6004A9460 /* spineboy.png */,
);
@ -1037,7 +1034,7 @@
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = "Craig Hinrichs";
};
buildConfigurationList = 9A5D2490170A94DA0030D4DD /* Build configuration list for PBXProject "Spine" */;
buildConfigurationList = 9A5D2490170A94DA0030D4DD /* Build configuration list for PBXProject "spine-cocos2d-iphone-ios" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
@ -1059,8 +1056,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
43C3286C170B0DA6004A9460 /* spineboy-skeleton.json in Resources */,
43C3286D170B0DA6004A9460 /* spineboy-walk.json in Resources */,
43C3286C170B0DA6004A9460 /* spineboy.json in Resources */,
43C3286E170B0DA6004A9460 /* spineboy.atlas in Resources */,
43C3286F170B0DA6004A9460 /* spineboy.png in Resources */,
43C3287D170B0DBE004A9460 /* Default-568h@2x.png in Resources */,
@ -1321,7 +1317,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
9A5D2490170A94DA0030D4DD /* Build configuration list for PBXProject "Spine" */ = {
9A5D2490170A94DA0030D4DD /* Build configuration list for PBXProject "spine-cocos2d-iphone-ios" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9A5D2641170A94DC0030D4DD /* Debug */,

View File

@ -1254,6 +1254,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@ -1265,6 +1266,8 @@
"\"../spine-c/include\"",
);
INFOPLIST_FILE = "Resources-mac/Info.plist";
OTHER_CFLAGS = "";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-lz",
"-lsqlite3",
@ -1279,6 +1282,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = NO;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Resources-mac/Prefix.pch";
@ -1289,6 +1293,8 @@
"\"../spine-c/include\"",
);
INFOPLIST_FILE = "Resources-mac/Info.plist";
OTHER_CFLAGS = "";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-lz",
"-lsqlite3",

View File

@ -29,6 +29,8 @@
#include <spine/spine.h>
#include "cocos2d.h"
@class CCSkeleton;
#ifdef __cplusplus
namespace spine {
extern "C" {
@ -37,13 +39,11 @@ extern "C" {
typedef struct {
AtlasPage super;
CCTexture2D* texture;
CCTextureAtlas* atlas;
CCTextureAtlas* textureAtlas;
} Cocos2dAtlasPage;
/**/
@class CCSkeleton;
typedef struct {
Skeleton super;
CCSkeleton* node;
@ -54,12 +54,13 @@ typedef struct {
typedef struct {
RegionAttachment super;
ccV3F_C4B_T2F_Quad quad;
CCTextureAtlas* atlas;
CCTextureAtlas* textureAtlas;
} Cocos2dRegionAttachment;
#ifdef __cplusplus
}
}
using namespace spine;
#endif
/**/
@ -69,6 +70,7 @@ typedef struct {
bool ownsAtlas;
bool ownsSkeleton;
bool ownsStateData;
Atlas* atlas;
@public
Skeleton* const skeleton;
@ -77,7 +79,7 @@ typedef struct {
bool debugSlots;
bool debugBones;
CCTextureAtlas* atlas; // All region attachments for a skeleton must use the same texture.
CCTextureAtlas* textureAtlas; // All region attachments for a skeleton must use the same texture.
unsigned int quadCount;
ccBlendFunc blendFunc;

View File

@ -35,7 +35,7 @@ void _Cocos2dAtlasPage_dispose (AtlasPage* page) {
_AtlasPage_deinit(SUPER(self));
[self->texture release];
[self->atlas release];
[self->textureAtlas release];
FREE(page);
}
@ -47,8 +47,8 @@ AtlasPage* AtlasPage_create (const char* name, const char* path) {
self->texture = [[CCTextureCache sharedTextureCache] addImage:@(path)];
[self->texture retain];
self->atlas = [[CCTextureAtlas alloc] initWithTexture:self->texture capacity:4];
[self->atlas retain];
self->textureAtlas = [[CCTextureAtlas alloc] initWithTexture:self->texture capacity:4];
[self->textureAtlas retain];
return SUPER(self);
}
@ -114,11 +114,11 @@ void _Cocos2dRegionAttachment_draw (Attachment* attachment, Slot* slot) {
quad->br.vertices.y = offset[6] * slot->bone->m10 + offset[7] * slot->bone->m11 + slot->bone->worldY;
// Cocos2d doesn't handle batching for us, so we'll just force a single texture per skeleton.
skeleton->node->atlas = self->atlas;
if (self->atlas.capacity <= skeleton->node->quadCount) {
if (![self->atlas resizeCapacity:self->atlas.capacity * 2]) return;
skeleton->node->textureAtlas = self->textureAtlas;
if (self->textureAtlas.capacity <= skeleton->node->quadCount) {
if (![self->textureAtlas resizeCapacity:self->textureAtlas.capacity * 2]) return;
}
[self->atlas updateQuad:quad atIndex:skeleton->node->quadCount++];
[self->textureAtlas updateQuad:quad atIndex:skeleton->node->quadCount++];
}
RegionAttachment* RegionAttachment_create (const char* name, AtlasRegion* region) {
@ -128,7 +128,7 @@ RegionAttachment* RegionAttachment_create (const char* name, AtlasRegion* region
VTABLE(Attachment, self) ->draw = _Cocos2dRegionAttachment_draw;
Cocos2dAtlasPage* page = SUB_CAST(Cocos2dAtlasPage, region->page);
self->atlas = page->atlas;
self->textureAtlas = page->textureAtlas;
CGSize size = page->texture.contentSizeInPixels;
float u = region->x / size.width;
float u2 = (region->x + region->width) / size.width;
@ -216,6 +216,7 @@ char* _Util_readFile (const char* path, int* length) {
CCSkeleton* node = [CCSkeleton create:skeletonData];
node->ownsSkeleton = true;
node->ownsAtlas = true;
node->atlas = atlas;
return node;
}
@ -248,8 +249,8 @@ char* _Util_readFile (const char* path, int* length) {
blendFunc.src = GL_ONE;
blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
timeScale = 1;
timeScale = 1;
[self setShaderProgram:[[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionTextureColor]];
[self scheduleUpdate];
@ -257,10 +258,11 @@ char* _Util_readFile (const char* path, int* length) {
}
- (void) dealloc {
Skeleton_dispose(skeleton);
if (ownsSkeleton) Skeleton_dispose(skeleton);
if (ownsStateData) AnimationStateData_dispose(state->data);
if (ownsAtlas) Atlas_dispose(atlas);
AnimationState_dispose(state);
[super dealloc];
[super dealloc];
}
- (void) update:(ccTime)deltaTime {
@ -283,7 +285,7 @@ char* _Util_readFile (const char* path, int* length) {
quadCount = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++)
if (skeleton->slots[i]->attachment) Attachment_draw(skeleton->slots[i]->attachment, skeleton->slots[i]);
if (atlas) [atlas drawNumberOfQuads:quadCount];
if (textureAtlas) [textureAtlas drawNumberOfQuads:quadCount];
if (debugSlots) {
// Slots.
@ -375,11 +377,11 @@ char* _Util_readFile (const char* path, int* length) {
// CCBlendProtocol
- (void) setBlendFunc:(ccBlendFunc)func {
self.blendFunc = func;
self.blendFunc = func;
}
- (ccBlendFunc) blendFunc {
return blendFunc;
return blendFunc;
}
@end