Skip to content

Commit f6dbb41

Browse files
author
Thayer J Andrews
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents 43772d2 + 4964238 commit f6dbb41

File tree

7 files changed

+145
-13
lines changed

7 files changed

+145
-13
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
url=https://github.com/slembcke/Chipmunk2D.git
44
[submodule "external/ogg"]
55
path = external/ogg
6-
url = [email protected]:apportable/ogg.git
6+
url=[email protected]:spritebuilder/ogg.git
77
branch = apportable
88
[submodule "external/tremor"]
99
path = external/tremor
10-
url = [email protected]:apportable/tremor.git
10+
url=[email protected]:spritebuilder/tremor.git
1111
branch = apportable

cocos2d-osx.xcodeproj/project.pbxproj

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,45 @@
892892
name = Frameworks;
893893
sourceTree = "<group>";
894894
};
895-
571CD02E19649E22003D460C /* Platform */ = {
895+
929D1B541954C28100B27340 /* Effects */ = {
896+
isa = PBXGroup;
897+
children = (
898+
B751D2581988896D00722D93 /* CCEffectGlass.h */,
899+
B751D2591988896D00722D93 /* CCEffectGlass.m */,
900+
B751D25A1988896D00722D93 /* CCEffectReflection.h */,
901+
B751D25B1988896D00722D93 /* CCEffectReflection.m */,
902+
B751D25C1988896D00722D93 /* CCEffectUtils.h */,
903+
B751D25D1988896D00722D93 /* CCEffectUtils.m */,
904+
929D1B551954C2A600B27340 /* CCEffect_Private.h */,
905+
929D1B561954C2A600B27340 /* CCEffect.h */,
906+
929D1B571954C2A600B27340 /* CCEffect.m */,
907+
929D1B581954C2A600B27340 /* CCEffectBrightness.h */,
908+
929D1B591954C2A600B27340 /* CCEffectBrightness.m */,
909+
929D1B5A1954C2A600B27340 /* CCEffectContrast.h */,
910+
929D1B5B1954C2A600B27340 /* CCEffectContrast.m */,
911+
92D1343A1954FC7A003833C4 /* CCEffectBlur.h */,
912+
929D1B5C1954C2A600B27340 /* CCEffectBlur.m */,
913+
9D23869A196F0BC4001B792B /* CCEffectHue.h */,
914+
9D23869B196F0BC4001B792B /* CCEffectHue.m */,
915+
929D1B5E1954C2A600B27340 /* CCEffectNode.h */,
916+
929D1B5F1954C2A600B27340 /* CCEffectNode.m */,
917+
929D1B601954C2A600B27340 /* CCEffectPixellate.h */,
918+
929D1B611954C2A600B27340 /* CCEffectPixellate.m */,
919+
929D1B621954C2A600B27340 /* CCEffectRenderer.h */,
920+
929D1B631954C2A600B27340 /* CCEffectRenderer.m */,
921+
9DDFEF6819635F0600CCE3DF /* CCEffectRefraction.h */,
922+
9DDFEF6919635F0600CCE3DF /* CCEffectRefraction.m */,
923+
929D1B641954C2A600B27340 /* CCEffectSaturation.h */,
924+
929D1B651954C2A600B27340 /* CCEffectSaturation.m */,
925+
929D1B661954C2A600B27340 /* CCEffectStack_Private.h */,
926+
92D134361954FC7A003833C4 /* CCEffectStackProtocol.h */,
927+
929D1B671954C2A600B27340 /* CCEffectStack.h */,
928+
929D1B681954C2A600B27340 /* CCEffectStack.m */,
929+
);
930+
name = Effects;
931+
sourceTree = "<group>";
932+
};
933+
571CD02E19649E22003D460C /* Platform */ = {
896934
isa = PBXGroup;
897935
children = (
898936
571CD02F19649E22003D460C /* Android */,

cocos2d-ui/CCBReader/CCAnimationManager.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ - (CCBSequence*)sequenceFromSequenceId:(int)seqId {
170170

171171
- (CCActionInterval*)actionFromKeyframe0:(CCBKeyframe*)kf0 andKeyframe1:(CCBKeyframe*)kf1 propertyName:(NSString*)name node:(CCNode*)node {
172172
float duration = kf1.time - kf0.time;
173-
173+
174174
if(kf0 && kf0.easingType==kCCBKeyframeEasingInstant) {
175175
duration = 0;
176176
}
@@ -515,13 +515,13 @@ - (void)runAnimationsForSequenceId:(int)seqId tweenDuration:(float) tweenDuratio
515515
}
516516
}
517517
}
518-
518+
519519
}
520520

521521

522522
}
523523

524-
_paused = NO;
524+
_paused = NO;
525525
}
526526

527527
- (void)runAnimationsForSequenceNamed:(NSString*)name tweenDuration:(float)tweenDuration {
@@ -856,8 +856,8 @@ - (CCActionSequence*)createActionForNode:(CCNode*)node sequenceProperty:(CCBSequ
856856
// Instant
857857
if(startKF.easingType==kCCBKeyframeEasingInstant) {
858858
[actions addObject:[CCActionDelay actionWithDuration:endKF.time-startKF.time]];
859-
}
860-
859+
}
860+
861861
// Apply Easing
862862
action = [self easeAction:action easingType:startKF.easingType easingOpt:startKF.easingOpt];
863863
[actions addObject:action];

cocos2d-ui/CCBReader/CCBReader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
NSMutableDictionary* actionManagers;
6060
NSMutableSet* animatedProps;
6161
NSMutableDictionary* nodeMapping;//Maps UUID -> Node
62+
NSMutableArray * postDeserializationUUIDFixup;
6263
}
6364

6465
/// -----------------------------------------------------------------------

cocos2d-ui/CCBReader/CCBReader.m

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#import "CCDirector_Private.h"
3838
#import "CCPhysics+ObjectiveChipmunk.h"
3939
#import "CCAnimationManager_Private.h"
40+
#import "CCEffectStack.h"
4041

4142
#ifdef CCB_ENABLE_UNZIP
4243
#import "SSZipArchive.h"
@@ -51,15 +52,20 @@
5152
@interface CCBFile : CCNode
5253
{
5354
CCNode* ccbFile;
55+
5456
}
5557
@property (nonatomic,strong) CCNode* ccbFile;
5658
@end
5759

5860

5961
@interface CCBReader()
62+
{
63+
64+
}
6065

6166
@property (nonatomic, copy) NSString *currentCCBFile;
6267

68+
6369
@end
6470

6571

@@ -122,7 +128,7 @@ - (id) init
122128
animationManager.rootContainerSize = [CCDirector sharedDirector].designSize;
123129

124130
nodeMapping = [NSMutableDictionary dictionary];
125-
131+
postDeserializationUUIDFixup = [NSMutableArray array];
126132
return self;
127133
}
128134

@@ -912,10 +918,12 @@ - (void) readPropertyForNode:(CCNode*) node parent:(CCNode*)parent isExtraProp:(
912918
else if(type == kCCBPropTypeNodeReference)
913919
{
914920
int uuid = readIntWithSign(self, NO);
915-
CCNode * mappedNode = nodeMapping[@(uuid)];
916-
NSAssert(mappedNode != nil, @"CCBReader: Failed to find node UUID:%i", uuid);
917-
[node setValue:mappedNode forKey:name];
918-
}
921+
922+
//Node references are fixed after the whole node graph is deserialized (since since the node ref may not be deserialized yet)
923+
NSArray * queuedFixupTask = @[node, name, @(uuid)];
924+
[postDeserializationUUIDFixup addObject:queuedFixupTask];
925+
926+
}
919927
else if(type == kCCBPropTypeFloatCheck)
920928
{
921929
float f = readFloat(self);
@@ -927,12 +935,71 @@ - (void) readPropertyForNode:(CCNode*) node parent:(CCNode*)parent isExtraProp:(
927935
[node setValue:@(f) forKey:name];
928936
}
929937
}
938+
else if(type == kCCBPropTypeEffects)
939+
{
940+
CCEffect * effect = [self readEffects];
941+
942+
if(effect)
943+
{
944+
//Hmmm..... Force it to write to @"effect" property.
945+
[node setValue:effect forKey:@"effect"];
946+
}
947+
948+
}
930949
else
931950
{
932951
NSAssert(false, @"[PROPERTY] %@ - Failed to read property type %d, node class name: \"%@\", name: \"%@\", in ccb file: \"%@\"", name, type, [node class], [node name], _currentCCBFile);
933952
}
934953
}
935954

955+
956+
957+
//Either returns a CCStackEffect or the one single effect.
958+
-(CCEffect*)readEffects
959+
{
960+
961+
int numberOfEffects = readIntWithSign(self, NO);
962+
963+
if(numberOfEffects == 0)
964+
{
965+
return nil;
966+
}
967+
968+
NSMutableArray * effectsStack = [NSMutableArray array];
969+
970+
for (int i = 0; i < numberOfEffects; i++) {
971+
NSString * className = [self readCachedString];
972+
973+
Class nodeClass = NSClassFromString(className);
974+
if (nodeClass == nil)
975+
{
976+
NSAssert(nil, @"CCBReader: Could not create class named: %@", className);
977+
return nil;
978+
}
979+
980+
CCEffect* effect = [[nodeClass alloc] init];
981+
982+
int propCount = readIntWithSign(self,NO);
983+
984+
for(int propIndex = 0; propIndex < propCount; propIndex++)
985+
{
986+
//Just lie and let the property reader do its work.
987+
[self readPropertyForNode:(CCNode*)effect parent:nil isExtraProp:NO];
988+
989+
}
990+
991+
if(numberOfEffects == 1)
992+
{
993+
return effect;
994+
}
995+
[effectsStack addObject:effect];
996+
997+
}
998+
999+
return [[CCEffectStack alloc] initWithArray:effectsStack];
1000+
1001+
}
1002+
9361003
- (BOOL)isPropertyKeySettable:(NSString *)key onInstance:(id)instance
9371004
{
9381005
if (!key || !instance || ([key length] == 0))
@@ -1071,6 +1138,24 @@ - (void) didLoadFromCCB
10711138
{
10721139
}
10731140

1141+
-(void)postDeserialization
1142+
{
1143+
//Post deserialization fixup.
1144+
for (NSArray * task in postDeserializationUUIDFixup) {
1145+
id node = task[0];
1146+
NSString * name = task[1];
1147+
int uuid = (int)[task[2] integerValue];
1148+
1149+
if(uuid == 0)
1150+
return;
1151+
1152+
CCNode * mappedNode = nodeMapping[@(uuid)];
1153+
NSAssert(mappedNode != nil, @"CCBReader: Failed to find node UUID:%i", uuid);
1154+
[node setValue:mappedNode forKey:name];
1155+
1156+
}
1157+
}
1158+
10741159
-(void)readJoints
10751160
{
10761161
int numJoints = readIntWithSign(self, NO);
@@ -1675,6 +1760,7 @@ - (CCNode*) readFileWithCleanUp:(BOOL)cleanUp actionManagers:(NSMutableDictionar
16751760

16761761
CCNode* node = [self readNodeGraphParent:NULL];
16771762
[self readJoints];
1763+
[self postDeserialization];
16781764

16791765
[actionManagers setObject:self.animationManager forKey:[NSValue valueWithPointer:(__bridge const void *)(node)]];
16801766

cocos2d-ui/CCBReader/CCBReader_Private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum {
4242
kCCBPropTypeColor4,
4343
kCCBPropTypeNodeReference,
4444
kCCBPropTypeFloatCheck,
45+
kCCBPropTypeEffects,
4546

4647
};
4748

cocos2d/CCPhysicsBody.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ -(void)setType:(CCPhysicsBodyType)type
272272
// Chipmunk body type cannot be changed from within a callback, need to make this safe.
273273
[space addPostStepBlock:^{_body.type = ToChipmunkBodyType[type];} key:self];
274274
} else {
275+
276+
if(self.type != type && self.type == CCPhysicsBodyTypeKinematic)
277+
{
278+
[self.node.physicsNode.kineticNodes removeObject:self.node];
279+
}
280+
275281
_body.type = ToChipmunkBodyType[type];
276282
}
277283
}

0 commit comments

Comments
 (0)