Skip to content

Commit 1a5c6a2

Browse files
committed
Merge branch 'v3.1' of https://github.com/cocos2d/cocos2d-iphone into v3.1
2 parents 871df4d + 8445bc1 commit 1a5c6a2

15 files changed

+35
-15
lines changed

cocos2d-ui/CCBReader/CCAnimationManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ -(void) onEnter {
8585

8686
- (void)addNode:(CCNode*)node andSequences:(NSDictionary*)seq
8787
{
88-
#ifdef DEBUG
88+
#if DEBUG
8989
//Sanity check sequences;
9090

9191
for (NSMutableDictionary* seqNodeProps in seq.allValues) {

cocos2d/CCDirector.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ -(void) calculateDeltaTime
265265
_dt = MAX(0,_dt);
266266
}
267267

268-
#ifdef DEBUG
268+
#if DEBUG
269269
// If we are debugging our code, prevent big delta time
270270
if( _dt > 0.2f )
271271
_dt = 1/60.0f;
@@ -864,7 +864,8 @@ -(void) showStats
864864
NSString *fpsstr = [[NSString alloc] initWithFormat:@"%.1f", _frameRate];
865865
[_FPSLabel setString:fpsstr];
866866

867-
NSString *draws = [[NSString alloc] initWithFormat:@"%4lu", (unsigned long)__ccNumberOfDraws];
867+
// Subtract one for the stat label's own batch. This caused a lot of confusion on the forums...
868+
NSString *draws = [[NSString alloc] initWithFormat:@"%4lu", (unsigned long)__ccNumberOfDraws - 1];
868869
[_drawsLabel setString:draws];
869870
}
870871

cocos2d/CCDrawNode.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ @implementation CCDrawNode {
5656

5757
+(void)initialize
5858
{
59+
// +initialize may be called due to loading a subclass.
60+
if(self != [CCDrawNode class]) return;
61+
5962
SHADER = [[CCShader alloc] initWithFragmentShaderSource:FRAGMENT_SHADER_SOURCE];
6063
}
6164

cocos2d/CCNode+Debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#import "CCNode.h"
2727

28-
#ifdef DEBUG
28+
#if DEBUG
2929

3030
/** Debugging extensions of CCNode. They are available when the DEBUG macro is defined at compile time. */
3131
@interface CCNode (Debug)

cocos2d/CCNode+Debug.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#import "CCNode+Debug.h"
2727
#import "CCNode_Private.h"
2828

29-
#ifdef DEBUG
29+
#if DEBUG
3030

3131
@implementation CCNode (Debug)
3232

cocos2d/CCPhysicsBody.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ -(void)didRemoveFromPhysicsNode:(CCPhysicsNode *)physics
514514
//The following are properties which we track on the parent nodes in order to update the child nodes.
515515
NSString * kDependantProperties[2] = { @"position", @"rotation"};
516516

517-
#ifdef DEBUG
517+
#if DEBUG
518518
//The following are properties which cannot be animated. Changing their values after onEnter in unhandled.
519519
NSString * kRestrictedProperties[3] = { @"scale", @"scaleX", @"scaleY"};
520520
#endif
@@ -531,7 +531,7 @@ -(void)trackParentTransformations:(CCPhysicsNode *)physics
531531
[node addObserver:self forKeyPath:kDependantProperties[i] options:NSKeyValueObservingOptionNew context:nil];
532532
}
533533

534-
#ifdef DEBUG
534+
#if DEBUG
535535
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
536536
{
537537
[node addObserver:self forKeyPath:kRestrictedProperties[i] options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
@@ -552,7 +552,7 @@ -(void)removeParentTransformTracking:(CCPhysicsNode *)physics
552552
{
553553
[node removeObserver:self forKeyPath:kDependantProperties[i]];
554554
}
555-
#ifdef DEBUG
555+
#if DEBUG
556556
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
557557
{
558558
[node removeObserver:self forKeyPath:kRestrictedProperties[i]];
@@ -567,7 +567,7 @@ -(void)removeParentTransformTracking:(CCPhysicsNode *)physics
567567

568568
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
569569
{
570-
#ifdef DEBUG
570+
#if DEBUG
571571
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
572572
{
573573
if([kRestrictedProperties[i] isEqualToString:keyPath])

cocos2d/CCRenderer.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ -(instancetype)initWithOptions:(NSDictionary *)options
170170

171171
+(void)initialize
172172
{
173+
// +initialize may be called due to loading a subclass.
174+
if(self != [CCBlendMode class]) return;
175+
173176
CCBLENDMODE_CACHE = [[CCBlendModeCache alloc] init];
174177

175178
// Add the default modes
@@ -276,6 +279,9 @@ @implementation CCRenderState {
276279

277280
+(void)initialize
278281
{
282+
// +initialize may be called due to loading a subclass.
283+
if(self != [CCRenderState class]) return;
284+
279285
CCRENDERSTATE_CACHE = [[CCRenderStateCache alloc] init];
280286
CCRENDERSTATE_DEBUGCOLOR = [[self alloc] initWithBlendMode:CCBLEND_DISABLED shader:[CCShader positionColorShader] shaderUniforms:@{}];
281287
}

cocos2d/CCShader.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ -(instancetype)copyWithZone:(NSZone *)zone
449449

450450
+(void)initialize
451451
{
452+
// +initialize may be called due to loading a subclass.
453+
if(self != [CCShader class]) return;
454+
452455
CC_SHADER_CACHE = [[CCShaderCache alloc] init];
453456

454457
// Setup the builtin shaders.

cocos2d/CCSpriteFrameCache.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ -(CCSpriteFrame*) spriteFrameByName:(NSString*)name
449449

450450
if (!frame)
451451
{
452+
// Check fileLookup.plist
453+
NSString *newName = [[CCFileUtils sharedFileUtils].filenameLookup objectForKey:name];
454+
name = newName ?: name;
455+
452456
// Try finding the frame in one of the registered sprite sheets
453457
NSString* spriteFrameFile = [_spriteFrameFileLookup objectForKey:name];
454458
if (spriteFrameFile) [self addSpriteFramesWithFile:spriteFrameFile];

cocos2d/CCTMXXMLParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ typedef enum ccTMXTileFlags_ {
7777
@property (nonatomic,readwrite) BOOL visible;
7878

7979
/** Layer Opacity. */
80-
@property (nonatomic,readwrite) unsigned char opacity;
80+
@property (nonatomic,readwrite) float opacity;
8181

8282
/** True to release ownership of layer tiles. */
8383
@property (nonatomic,readwrite) BOOL ownTiles;

0 commit comments

Comments
 (0)