Skip to content

Commit 0125b7f

Browse files
committed
Merge branch 'develop' into metal-hacking
Conflicts: cocos2d-ios.xcodeproj/project.pbxproj
2 parents ad3f526 + b4fd3f5 commit 0125b7f

File tree

7 files changed

+124
-55
lines changed

7 files changed

+124
-55
lines changed

cocos2d-ios.xcodeproj/project.pbxproj

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@
281281
D28A2E1B1954F68D00ADC03D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E1A1954F68D00ADC03D /* QuartzCore.framework */; };
282282
D28A2E1D1954F7E000ADC03D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E1C1954F7E000ADC03D /* OpenGLES.framework */; };
283283
D28A2E211954F85700ADC03D /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E201954F85700ADC03D /* AVFoundation.framework */; };
284+
D28B2E7A19CBA89A00DC6E08 /* CCEffectColorChannelOffset.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DBCA31319B68BE400EFE96D /* CCEffectColorChannelOffset.m */; };
284285
D291DCC2195B2FA100278EC0 /* libObjectiveChipmunk-iPhone.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B759E52D1880C66900E8166C /* libObjectiveChipmunk-iPhone.a */; };
285286
D299CE7A19C2910B00519CBB /* CCEffectDFInnerGlow.h in Headers */ = {isa = PBXBuildFile; fileRef = D299CE7819C2910B00519CBB /* CCEffectDFInnerGlow.h */; };
286287
D299CE7B19C2910B00519CBB /* CCEffectDFInnerGlow.h in Headers */ = {isa = PBXBuildFile; fileRef = D299CE7819C2910B00519CBB /* CCEffectDFInnerGlow.h */; };
@@ -598,20 +599,20 @@
598599
remoteGlobalIDString = D309B21217EFE2EF00AA52C8;
599600
remoteInfo = "ObjectiveChipmunk-iPhone";
600601
};
602+
D28B2E7D19CBA89A00DC6E08 /* PBXContainerItemProxy */ = {
603+
isa = PBXContainerItemProxy;
604+
containerPortal = FC39961319C3B92F00C93E5E /* ObjectAL.xcodeproj */;
605+
proxyType = 2;
606+
remoteGlobalIDString = D369B53219C8E73C00BA46EA;
607+
remoteInfo = "ObjectAL (Mac)";
608+
};
601609
D2FEB60F194F6C9E00FC0574 /* PBXContainerItemProxy */ = {
602610
isa = PBXContainerItemProxy;
603611
containerPortal = B759E5281880C66900E8166C /* Chipmunk7-ios.xcodeproj */;
604612
proxyType = 1;
605613
remoteGlobalIDString = D309B21217EFE2EF00AA52C8;
606614
remoteInfo = "ObjectiveChipmunk-iPhone";
607615
};
608-
D369416219CFDF170092A0BD /* PBXContainerItemProxy */ = {
609-
isa = PBXContainerItemProxy;
610-
containerPortal = FC39961319C3B92F00C93E5E /* ObjectAL.xcodeproj */;
611-
proxyType = 2;
612-
remoteGlobalIDString = D369B53219C8E73C00BA46EA;
613-
remoteInfo = "ObjectAL (Mac)";
614-
};
615616
FC39961A19C3B92F00C93E5E /* PBXContainerItemProxy */ = {
616617
isa = PBXContainerItemProxy;
617618
containerPortal = FC39961319C3B92F00C93E5E /* ObjectAL.xcodeproj */;
@@ -766,7 +767,7 @@
766767
5BC3CB5219626E4F00C4F0D0 /* CCGestureListener.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = CCGestureListener.java; sourceTree = "<group>"; };
767768
5BC3CB5719626FA000C4F0D0 /* CCGestureListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGestureListener.h; path = Android/CCGestureListener.h; sourceTree = "<group>"; };
768769
5BC3CB5819626FA000C4F0D0 /* CCGestureListener.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCGestureListener.m; path = Android/CCGestureListener.m; sourceTree = "<group>"; };
769-
5BF3267A195F8D8800D9A51A /* cocos2dJava.jar */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = archive.jar; path = cocos2dJava.jar; sourceTree = BUILT_PRODUCTS_DIR; };
770+
5BF3267A195F8D8800D9A51A /* cocos2dJava.jar */ = {isa = PBXFileReference; explicitFileType = compiled.java.jar; includeInIndex = 0; path = cocos2dJava.jar; sourceTree = BUILT_PRODUCTS_DIR; };
770771
5BF3268C195F8E0300D9A51A /* CCActivity.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = CCActivity.java; sourceTree = "<group>"; };
771772
5BF3268D195F8E0300D9A51A /* CCGLView.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = CCGLView.java; sourceTree = "<group>"; };
772773
5BF32696195F947800D9A51A /* CCActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCActivity.h; path = Android/CCActivity.h; sourceTree = "<group>"; };
@@ -1713,7 +1714,7 @@
17131714
children = (
17141715
FC39961B19C3B92F00C93E5E /* libObjectAL.a */,
17151716
FC39961F19C3B92F00C93E5E /* libObjectAL (Android).a */,
1716-
D369416319CFDF170092A0BD /* libObjectAL (Mac).a */,
1717+
D28B2E7E19CBA89A00DC6E08 /* libObjectAL (Mac).a */,
17171718
);
17181719
name = Products;
17191720
sourceTree = "<group>";
@@ -2136,11 +2137,11 @@
21362137
remoteRef = B759E52C1880C66900E8166C /* PBXContainerItemProxy */;
21372138
sourceTree = BUILT_PRODUCTS_DIR;
21382139
};
2139-
D369416319CFDF170092A0BD /* libObjectAL (Mac).a */ = {
2140+
D28B2E7E19CBA89A00DC6E08 /* libObjectAL (Mac).a */ = {
21402141
isa = PBXReferenceProxy;
21412142
fileType = archive.ar;
21422143
path = "libObjectAL (Mac).a";
2143-
remoteRef = D369416219CFDF170092A0BD /* PBXContainerItemProxy */;
2144+
remoteRef = D28B2E7D19CBA89A00DC6E08 /* PBXContainerItemProxy */;
21442145
sourceTree = BUILT_PRODUCTS_DIR;
21452146
};
21462147
FC39961B19C3B92F00C93E5E /* libObjectAL.a */ = {
@@ -2381,6 +2382,7 @@
23812382
D2FEB6E7194F6C9E00FC0574 /* ZipUtils.m in Sources */,
23822383
D2FEB6EA194F6C9E00FC0574 /* CCEffectStack.m in Sources */,
23832384
D2FEB6EC194F6C9E00FC0574 /* CCRenderTexture.m in Sources */,
2385+
D28B2E7A19CBA89A00DC6E08 /* CCEffectColorChannelOffset.m in Sources */,
23842386
D2FEB6ED194F6C9E00FC0574 /* CCMotionStreak.m in Sources */,
23852387
D2FEB6EE194F6C9E00FC0574 /* CCSpriteFrame.m in Sources */,
23862388
D2FEB6EF194F6C9E00FC0574 /* CCSpriteFrameCache.m in Sources */,

cocos2d-tests-ios.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
B7EE69811818760700B983FE /* CCSprite9SliceTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B7EE69801818760700B983FE /* CCSprite9SliceTest.m */; };
6767
B7EE69CF1819D82300B983FE /* CCLayoutTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B7EE69CE1819D82300B983FE /* CCLayoutTest.m */; };
6868
B7EE6A28181B075E00B983FE /* CCSliderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B7EE6A27181B075E00B983FE /* CCSliderTest.m */; };
69+
D23CD73119CB881200C7EB14 /* CCShaders.metal in Resources */ = {isa = PBXBuildFile; fileRef = D3C1281C199D43E0005D2119 /* CCShaders.metal */; };
6970
D24FAEED198014C80043E27D /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D34CD3C118ABEE9C00D8E537 /* GLKit.framework */; };
7071
D28A2E181954F68200ADC03D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E171954F68200ADC03D /* UIKit.framework */; };
7172
D28A2E1F1954F7E900ADC03D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E1E1954F7E900ADC03D /* OpenGLES.framework */; };
@@ -80,7 +81,6 @@
8081
D34CD3C518ABF4AA00D8E537 /* CCRendererTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D34CD3C418ABF4AA00D8E537 /* CCRendererTests.m */; };
8182
D3870C6018B440150033D885 /* SpritePerformanceTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D3870C5F18B440150033D885 /* SpritePerformanceTest.m */; };
8283
D3B2A7E5187DD60B00406C5A /* CCBMFontTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D3B2A7E4187DD60B00406C5A /* CCBMFontTest.m */; };
83-
D3C1281D199D43E0005D2119 /* CCShaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = D3C1281C199D43E0005D2119 /* CCShaders.metal */; };
8484
D3C9C867188078B900C58900 /* CCSchedulerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D3C9C866188078B900C58900 /* CCSchedulerTest.m */; };
8585
D3D6CF5F18BD5F0500A51531 /* CCRendererTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D3D6CF5E18BD5F0500A51531 /* CCRendererTest.m */; };
8686
D4AFE9131977100000261299 /* A Damn Mess.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D4AFE8D81977100000261299 /* A Damn Mess.ttf */; };
@@ -874,6 +874,7 @@
874874
D4AFE9371977100000261299 /* konqa32-hd.png in Resources */,
875875
D4AFE9161977100000261299 /* arial-unicode-26.fnt in Resources */,
876876
B7E2621417E7D34D007067F0 /* Icon-Small.png in Resources */,
877+
D23CD73119CB881200C7EB14 /* CCShaders.metal in Resources */,
877878
D4AFE9361977100000261299 /* konqa32-hd.fnt in Resources */,
878879
D4AFE93C1977100000261299 /* larabie-16.plist in Resources */,
879880
D4AFE93A1977100000261299 /* larabie-16-hd.plist in Resources */,
@@ -952,7 +953,6 @@
952953
D3870C6018B440150033D885 /* SpritePerformanceTest.m in Sources */,
953954
B71B088217EA5B6A0082EBC0 /* CCScrollViewTest.m in Sources */,
954955
B7EE697918186D5200B983FE /* CCTextFieldTest.m in Sources */,
955-
D3C1281D199D43E0005D2119 /* CCShaders.metal in Sources */,
956956
B7E2620017E7D321007067F0 /* AppDelegate.m in Sources */,
957957
0E28FE1A197FCE4500F78989 /* CCCacheTest.m in Sources */,
958958
B77060AB1832E3310043CC67 /* CCTextureCacheTest.m in Sources */,

cocos2d-ui-tests/tests/CCEffectsTest.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,12 @@ -(void)setupBloomEffectTest
810810
sampleSprite3.positionType = CCPositionTypeNormalized;
811811

812812
// Blend glow maps test
813+
CCEffectHue *hueEffect = [CCEffectHue effectWithHue:60.0f];
813814
CCEffectBloom* glowEffect3 = [CCEffectBloom effectWithBlurRadius:8 intensity:1.0f luminanceThreshold:1.0f - ((float)i/(float)(steps-1))];
814815
glowEffect3.padding = CGSizeMake(10.0f, 10.0f);
815-
sampleSprite3.effect = glowEffect3;
816816

817+
sampleSprite3.effect = [CCEffectStack effectWithArray:@[glowEffect3, hueEffect]];
818+
817819
[self.contentNode addChild:sampleSprite3];
818820
}
819821
}
@@ -940,7 +942,7 @@ -(void)setupStackTest
940942
[CCEffectBrightness effectWithBrightness:0.25f],
941943
[CCEffectContrast effectWithContrast:1.0f],
942944
[CCEffectPixellate effectWithBlockSize:8.0f],
943-
[CCEffectSaturation effectWithSaturation:-1.0f],
945+
[CCEffectSaturation effectWithSaturation:1.0f],
944946
[CCEffectHue effectWithHue:90.0f],
945947
[CCEffectGlass effectWithShininess:1.0f refraction:0.75f refractionEnvironment:refractEnvironment reflectionEnvironment:reflectEnvironment],
946948
[CCEffectRefraction effectWithRefraction:0.75f environment:refractEnvironment],
@@ -954,7 +956,9 @@ -(void)setupStackTest
954956
sprite.position = ccp(0.5f, 0.5f);
955957
sprite.scale = 0.5f;
956958

957-
sprite.effect = [CCEffectStack effects:effects[7], effects[4], nil];
959+
CCEffectStack *stack1 = [CCEffectStack effects:effects[7], effects[6], nil];
960+
CCEffectStack *stack2 = [CCEffectStack effects:effects[5], effects[4], nil];
961+
sprite.effect = [CCEffectStack effects:stack1, stack2, nil];
958962

959963
sprite.normalMapSpriteFrame = [CCSpriteFrame frameWithImageNamed:@"Images/ShinyBallNormals.png"];
960964
sprite.colorRGBA = [CCColor colorWithRed:0.75f green:0.75f blue:0.75f alpha:0.75f];
@@ -1024,7 +1028,7 @@ -(void)setupPerformanceTest
10241028

10251029
CGSize containerSize = self.contentNode.contentSizeInPoints;
10261030

1027-
const float footprintScale = 1.1f;
1031+
const float footprintScale = 0.5f;
10281032

10291033
NSString *spriteImage = @"Images/r1.png";
10301034
CCSprite *sprite = [CCSprite spriteWithImageNamed:spriteImage];

cocos2d/CCEffect.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ -(id)initWithIndex:(NSUInteger)indexInEffect
250250
return self;
251251
}
252252

253+
-(instancetype)copyWithZone:(NSZone *)zone
254+
{
255+
CCEffectRenderPass *newPass = [[CCEffectRenderPass allocWithZone:zone] initWithIndex:_indexInEffect];
256+
newPass.texCoord1Mapping = _texCoord1Mapping;
257+
newPass.texCoord2Mapping = _texCoord2Mapping;
258+
newPass.blendMode = _blendMode;
259+
newPass.shader = _shader;
260+
newPass.beginBlocks = _beginBlocks;
261+
newPass.updateBlocks = _updateBlocks;
262+
newPass.endBlocks = _endBlocks;
263+
newPass.debugLabel = _debugLabel;
264+
return newPass;
265+
}
266+
253267
-(void)begin:(CCTexture *)previousPassTexture
254268
{
255269
for (CCEffectRenderPassBeginBlock block in _beginBlocks)

cocos2d/CCEffectStack.m

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ - (CCEffectPrepareStatus)prepareForRendering
186186
int effectIndex = 0;
187187
for (NSArray *stitchList in stitchLists)
188188
{
189-
NSAssert(stitchList.count > 0, @"Encountered an empty stitch list which shouldn't happen.");
190-
[stitchedEffects addObject:[self stitchEffects:stitchList startIndex:effectIndex]];
189+
[stitchedEffects addObject:[CCEffectStack stitchEffects:stitchList startIndex:effectIndex]];
191190
effectIndex += stitchList.count;
192191
}
193192
}
@@ -222,16 +221,20 @@ - (BOOL)readyForRendering
222221

223222
#pragma mark - Internal
224223

225-
-(CCEffect *)stitchEffects:(NSArray*)effects startIndex:(int)startIndex
224+
+ (CCEffect *)stitchEffects:(NSArray*)stitchList startIndex:(int)startIndex
226225
{
226+
NSAssert(stitchList.count > 0, @"Encountered an empty stitch list which shouldn't happen.");
227+
227228
NSMutableArray* allFragFunctions = [[NSMutableArray alloc] init];
228229
NSMutableArray* allFragUniforms = [[NSMutableArray alloc] init];
229230
NSMutableArray* allVertexFunctions = [[NSMutableArray alloc] init];
230231
NSMutableArray* allVertexUniforms = [[NSMutableArray alloc] init];
231232
NSMutableArray* allVaryings = [[NSMutableArray alloc] init];
232233

234+
// Even if we're only handed one effect in this stitch list, we have to run it through the
235+
// name mangling code below because all effects in a stack share one uniform namespace.
233236
int effectIndex = startIndex;
234-
for(CCEffect* effect in effects)
237+
for(CCEffect* effect in stitchList)
235238
{
236239
// Construct the prefix to use for name mangling.
237240
NSString *effectPrefix = [NSString stringWithFormat:@"%@_%d_", effect.debugName, effectIndex];
@@ -291,34 +294,53 @@ -(CCEffect *)stitchEffects:(NSArray*)effects startIndex:(int)startIndex
291294
// and last effects in the stitch list. If the "stitch before" flag is set on the
292295
// first effect then set it in the resulting effect. If the "stitch after" flag is
293296
// set in the last effect then set it in the resulting effect.
294-
CCEffect *firstEffect = [effects firstObject];
295-
CCEffect *lastEffect = [effects lastObject];
297+
CCEffect *firstEffect = [stitchList firstObject];
298+
CCEffect *lastEffect = [stitchList lastObject];
296299
stitchedEffect.stitchFlags = (firstEffect.stitchFlags & CCEffectFunctionStitchBefore) | (lastEffect.stitchFlags & CCEffectFunctionStitchAfter);
297300

298-
// Create a new render pass object and set its shader from the stitched effect
299-
// that was created above.
300-
CCEffectRenderPass *newPass = [[CCEffectRenderPass alloc] init];
301-
newPass.debugLabel = @"CCEffectStack_Stitched pass 0";
302-
newPass.shader = stitchedEffect.shader;
303-
304-
NSMutableArray *beginBlocks = [[NSMutableArray alloc] init];
305-
NSMutableArray *endBlocks = [[NSMutableArray alloc] init];
306-
307-
for (CCEffect *effect in effects)
301+
if (stitchList.count == 1)
308302
{
309-
// Copy the begin and end blocks from the input passes into the new pass.
310-
for (CCEffectRenderPass *pass in effect.renderPasses)
303+
// If there was only one effect in the stitch list copy its render
304+
// passes into the output stitched effect. Update the copied passes
305+
// so they point to the new shader in the stitched effect.
306+
307+
NSMutableArray *renderPasses = [[NSMutableArray alloc] init];
308+
for (CCEffectRenderPass *pass in firstEffect.renderPasses)
311309
{
312-
[beginBlocks addObjectsFromArray:pass.beginBlocks];
313-
[endBlocks addObjectsFromArray:pass.endBlocks];
310+
CCEffectRenderPass *newPass = [pass copy];
311+
newPass.shader = stitchedEffect.shader;
312+
[renderPasses addObject:newPass];
314313
}
314+
stitchedEffect.renderPasses = renderPasses;
315315
}
316-
317-
newPass.beginBlocks = beginBlocks;
318-
newPass.endBlocks = endBlocks;
319-
320-
stitchedEffect.renderPasses = @[newPass];
321-
316+
else
317+
{
318+
// If there were multiple effects in the stitch list, create a new render
319+
// pass object, set its shader to the shader from the stitched effect, and
320+
// copy all blocks from the input passes.
321+
CCEffectRenderPass *newPass = [[CCEffectRenderPass alloc] init];
322+
newPass.debugLabel = @"CCEffectStack_Stitched pass 0";
323+
newPass.shader = stitchedEffect.shader;
324+
325+
NSMutableArray *beginBlocks = [[NSMutableArray alloc] init];
326+
NSMutableArray *endBlocks = [[NSMutableArray alloc] init];
327+
328+
for (CCEffect *effect in stitchList)
329+
{
330+
// Copy the begin and end blocks from the input passes into the new pass.
331+
for (CCEffectRenderPass *pass in effect.renderPasses)
332+
{
333+
[beginBlocks addObjectsFromArray:pass.beginBlocks];
334+
[endBlocks addObjectsFromArray:pass.endBlocks];
335+
}
336+
}
337+
338+
newPass.beginBlocks = beginBlocks;
339+
newPass.endBlocks = endBlocks;
340+
341+
stitchedEffect.renderPasses = @[newPass];
342+
}
343+
322344
return stitchedEffect;
323345
}
324346

@@ -328,7 +350,7 @@ + (NSDictionary *)varyingsByApplyingPrefix:(NSString *)prefix toVaryings:(NSArra
328350
for(CCEffectVarying *varying in varyings)
329351
{
330352
NSString *prefixedName = [NSString stringWithFormat:@"%@%@", prefix, varying.name];
331-
CCEffectVarying *prefixedVarying = [[CCEffectVarying alloc] initWithType:varying.type name:prefixedName];
353+
CCEffectVarying *prefixedVarying = [[CCEffectVarying alloc] initWithType:varying.type name:prefixedName count:varying.count];
332354
[varyingReplacements setObject:prefixedVarying forKey:varying.name];
333355
}
334356
return [varyingReplacements copy];

cocos2d/CCTMXXMLParser.m

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,16 @@ - (void) dealloc
192192

193193
- (void) parseXMLData:(NSData*)data
194194
{
195-
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
196-
197-
// we'll do the parsing
198-
[parser setDelegate:self];
199-
[parser setShouldProcessNamespaces:NO];
200-
[parser setShouldReportNamespacePrefixes:NO];
201-
[parser setShouldResolveExternalEntities:NO];
202-
[parser parse];
203-
204-
NSAssert1( ![parser parserError], @"Error parsing TMX data: %@.", [NSString stringWithCharacters:[data bytes] length:[data length]] );
195+
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
196+
197+
// we'll do the parsing
198+
[parser setDelegate:self];
199+
[parser setShouldProcessNamespaces:NO];
200+
[parser setShouldReportNamespacePrefixes:NO];
201+
[parser setShouldResolveExternalEntities:NO];
202+
[parser parse];
203+
204+
NSAssert1( ![parser parserError], @"Error parsing TMX data: %@.", [NSString stringWithCharacters:[data bytes] length:[data length]] );
205205
}
206206

207207
- (void) parseXMLString:(NSString *)xmlString
@@ -252,7 +252,13 @@ -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName name
252252

253253
_currentFirstGID = [[attributeDict objectForKey:@"firstgid"] intValue];
254254

255-
[self parseXMLFile:externalTilesetFilename];
255+
// since the xml parser is not reentrant, we need to invoke each child xml parser in its own queue
256+
dispatch_queue_t reentrantAvoidanceQueue = dispatch_queue_create("xmlParserSafeQueue", DISPATCH_QUEUE_SERIAL);
257+
dispatch_async(reentrantAvoidanceQueue, ^{
258+
[self parseXMLFile:externalTilesetFilename];
259+
});
260+
dispatch_sync(reentrantAvoidanceQueue, ^{ });
261+
256262
} else {
257263
CCTiledMapTilesetInfo *tileset = [CCTiledMapTilesetInfo new];
258264
tileset.name = [attributeDict objectForKey:@"name"];

cocos2d/Platforms/iOS/CCAppDelegate.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,27 @@ - (void) setupCocos2dWithOptions:(NSDictionary*)config
261261

262262
// make main window visible
263263
[window_ makeKeyAndVisible];
264+
265+
[self forceOrientation];
266+
}
267+
268+
// iOS8 hack around orientation bug
269+
-(void)forceOrientation
270+
{
271+
#if __CC_PLATFORM_IOS && defined(__IPHONE_8_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
272+
if([navController_.screenOrientation isEqual:CCScreenOrientationAll])
273+
{
274+
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationUnknown];
275+
}
276+
else if([navController_.screenOrientation isEqual:CCScreenOrientationPortrait])
277+
{
278+
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait | UIDeviceOrientationPortraitUpsideDown];
279+
}
280+
else
281+
{
282+
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft | UIDeviceOrientationLandscapeRight];
283+
}
284+
#endif
264285
}
265286

266287
// getting a call, pause the game

0 commit comments

Comments
 (0)