Skip to content

Commit 2cd5c4d

Browse files
committed
Merge branch 'v3.0' of github:cocos2d/cocos2d-iphone into v3.0
2 parents fcbbcfa + 48bc290 commit 2cd5c4d

File tree

8 files changed

+57
-61
lines changed

8 files changed

+57
-61
lines changed

cocos2d-ui/CCBReader/CCBAnimationManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
id __unsafe_unretained owner;
5252
CGSize rootContainerSize;
5353

54-
NSObject<CCBAnimationManagerDelegate>* delegate;
54+
__weak NSObject<CCBAnimationManagerDelegate>* delegate;
5555
CCBSequence* runningSequence;
5656

5757
void (^block)(id sender);
@@ -61,7 +61,7 @@
6161
@property (nonatomic,unsafe_unretained) CCNode* rootNode;
6262
@property (nonatomic,unsafe_unretained) id owner;
6363
@property (nonatomic,assign) CGSize rootContainerSize;
64-
@property (nonatomic,strong) NSObject<CCBAnimationManagerDelegate>* delegate;
64+
@property (nonatomic,weak) NSObject<CCBAnimationManagerDelegate>* delegate;
6565
@property (unsafe_unretained, nonatomic,readonly) NSString* runningSequenceName;
6666
@property (nonatomic,readonly) NSString* lastCompletedSequenceName;
6767

cocos2d-ui/CCScrollView.m

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,16 @@ @interface CCTapDownGestureRecognizer : UIGestureRecognizer
6666

6767
@implementation CCTapDownGestureRecognizer
6868

69-
-(void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
69+
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
7070
{
7171
if (self.state == UIGestureRecognizerStatePossible)
7272
{
7373
self.state = UIGestureRecognizerStateRecognized;
7474
}
7575
}
7676

77-
-(void)touchMoved:(UITouch *)touch withEvent:(UIEvent *)event
78-
{
79-
self.state = UIGestureRecognizerStateFailed;
80-
}
81-
82-
-(void)touchEnded:(UITouch *)touch withEvent:(UIEvent *)event
83-
{
84-
self.state = UIGestureRecognizerStateFailed;
85-
}
8677
@end
78+
8779
#endif
8880

8981

cocos2d/CCLabelTTF.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
@property (nonatomic,strong) NSString* fontName;
6565

6666
/** The font size of the text. */
67-
@property (nonatomic,assign) float fontSize;
67+
@property (nonatomic,assign) CGFloat fontSize;
6868

6969
/** The color of the text (If not using shadow or outline). */
7070
@property (nonatomic,strong) CCColor* fontColor;
@@ -90,10 +90,10 @@
9090
@property (nonatomic,assign) BOOL adjustsFontSizeToFit;
9191

9292
/** Used together with adjustsFontSizeToFit. Fonts will not be scaled down below this size (the label will instead be clipped). */
93-
@property (nonatomic,assign) float minimumFontSize;
93+
@property (nonatomic,assign) CGFloat minimumFontSize;
9494

9595
/** Adjusts the fonts baseline, the value is set in points. */
96-
@property (nonatomic,assign) float baselineAdjustment;
96+
@property (nonatomic,assign) CGFloat baselineAdjustment;
9797

9898

9999
/// -----------------------------------------------------------------------
@@ -113,7 +113,7 @@
113113
@property (nonatomic,assign) CCPositionType shadowOffsetType;
114114

115115
/** The blur radius of the shadow. */
116-
@property (nonatomic,assign) float shadowBlurRadius;
116+
@property (nonatomic,assign) CGFloat shadowBlurRadius;
117117

118118

119119
/// -----------------------------------------------------------------------
@@ -124,7 +124,7 @@
124124
@property (nonatomic,strong) CCColor* outlineColor;
125125

126126
/** The width of the text's outline. */
127-
@property (nonatomic,assign) float outlineWidth;
127+
@property (nonatomic,assign) CGFloat outlineWidth;
128128

129129

130130
/// -----------------------------------------------------------------------

cocos2d/CCLabelTTF.m

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ - (id) initWithAttributedString:(NSAttributedString *)attrString dimensions:(CGS
110110
}
111111

112112
// This is a private initializer
113-
- (id) initWithAttributedString:(NSAttributedString *)attrString fontName:(NSString*)fontName fontSize:(float)fontSize dimensions:(CGSize)dimensions
113+
- (id) initWithAttributedString:(NSAttributedString *)attrString fontName:(NSString*)fontName fontSize:(CGFloat)fontSize dimensions:(CGSize)dimensions
114114
{
115115
if ( (self = [super init]) )
116116
{
@@ -181,7 +181,7 @@ - (void)setFontName:(NSString*)fontName
181181
}
182182
}
183183

184-
- (void) setFontSize:(float)fontSize
184+
- (void) setFontSize:(CGFloat)fontSize
185185
{
186186
if( fontSize != _fontSize ) {
187187
_fontSize = fontSize;
@@ -207,7 +207,7 @@ - (void) setFontColor:(CCColor*)fontColor
207207
}
208208
}
209209

210-
- (void) setMinimumFontSize:(float)minimumFontSize
210+
- (void) setMinimumFontSize:(CGFloat)minimumFontSize
211211
{
212212
if (minimumFontSize != _minimumFontSize)
213213
{
@@ -274,7 +274,7 @@ -(CGPoint)shadowOffsetInPoints
274274
return [self convertPositionToPoints:self.shadowOffset type:_shadowOffsetType];
275275
}
276276

277-
- (void) setShadowBlurRadius:(float)shadowBlurRadius
277+
- (void) setShadowBlurRadius:(CGFloat)shadowBlurRadius
278278
{
279279
if (_shadowBlurRadius != shadowBlurRadius)
280280
{
@@ -292,7 +292,7 @@ - (void) setOutlineColor:(CCColor*)outlineColor
292292
}
293293
}
294294

295-
- (void) setOutlineWidth:(float)outlineWidth
295+
- (void) setOutlineWidth:(CGFloat)outlineWidth
296296
{
297297
if (outlineWidth != _outlineWidth)
298298
{
@@ -484,27 +484,27 @@ - (CCTexture*) createTextureWithAttributedString:(NSAttributedString*)attributed
484484

485485
CGSize originalDimensions = _dimensions;
486486

487-
CGFloat scale = [CCDirector sharedDirector].contentScaleFactor;
487+
CGFloat scale = [CCDirector sharedDirector].contentScaleFactor;
488488
originalDimensions.width *= scale;
489489
originalDimensions.height *= scale;
490490

491491
CGSize dimensions = originalDimensions;
492492

493-
float shadowBlurRadius = _shadowBlurRadius * scale;
493+
CGFloat shadowBlurRadius = _shadowBlurRadius * scale;
494494
CGPoint shadowOffset = ccpMult(self.shadowOffsetInPoints, scale);
495-
float outlineWidth = _outlineWidth * scale;
495+
CGFloat outlineWidth = _outlineWidth * scale;
496496

497497
BOOL hasShadow = (_shadowColor.alpha > 0);
498498
BOOL hasOutline = (_outlineColor.alpha > 0 && _outlineWidth > 0);
499499

500-
float xOffset = 0;
501-
float yOffset = 0;
502-
float scaleFactor = 1;
500+
CGFloat xOffset = 0;
501+
CGFloat yOffset = 0;
502+
CGFloat scaleFactor = 1;
503503

504-
float xPadding = 0;
505-
float yPadding = 0;
506-
float wDrawArea = 0;
507-
float hDrawArea = 0;
504+
CGFloat xPadding = 0;
505+
CGFloat yPadding = 0;
506+
CGFloat wDrawArea = 0;
507+
CGFloat hDrawArea = 0;
508508

509509
// Calculate padding
510510
if (hasShadow)
@@ -542,7 +542,7 @@ - (CCTexture*) createTextureWithAttributedString:(NSAttributedString*)attributed
542542
// Handle strings with fixed dimensions
543543
if (_adjustsFontSizeToFit)
544544
{
545-
float fontSize = [attributedString singleFontSize];
545+
CGFloat fontSize = [attributedString singleFontSize];
546546
if (fontSize)
547547
{
548548
// This is a string that can be resized (it only uses one font and size)
@@ -552,8 +552,8 @@ - (CCTexture*) createTextureWithAttributedString:(NSAttributedString*)attributed
552552
CGSize wantedSize = [attributedString boundingRectWithSize:CGSizeZero options:NSStringDrawingUsesLineFragmentOrigin].size;
553553
#endif
554554

555-
float wScaleFactor = 1;
556-
float hScaleFactor = 1;
555+
CGFloat wScaleFactor = 1;
556+
CGFloat hScaleFactor = 1;
557557
if (wantedSize.width > wDrawArea)
558558
{
559559
wScaleFactor = wDrawArea/wantedSize.width;
@@ -568,8 +568,8 @@ - (CCTexture*) createTextureWithAttributedString:(NSAttributedString*)attributed
568568

569569
if (scaleFactor != 1)
570570
{
571-
float newFontSize = fontSize * scaleFactor;
572-
float minFontSize = _minimumFontSize * scale;
571+
CGFloat newFontSize = fontSize * scaleFactor;
572+
CGFloat minFontSize = _minimumFontSize * scale;
573573
if (minFontSize && newFontSize < minFontSize) newFontSize = minFontSize;
574574
attributedString = [attributedString copyWithNewFontSize:newFontSize];
575575
}
@@ -682,7 +682,7 @@ - (CCTexture*) createTextureWithAttributedString:(NSAttributedString*)attributed
682682
[[NSAffineTransform transform] set];
683683

684684
// XXX: The shadows are for some reason scaled on OS X if a retina display is connected
685-
float retinaFix = 1;
685+
CGFloat retinaFix = 1;
686686
for (NSScreen* screen in [NSScreen screens])
687687
{
688688
if (screen.backingScaleFactor > retinaFix) retinaFix = screen.backingScaleFactor;
@@ -802,23 +802,23 @@ - (BOOL) updateTextureOld
802802
- (CCTexture*) createTextureWithString:(NSString*) string useFullColor:(BOOL)useFullColor
803803
{
804804
// Scale everything up by content scale
805-
CGFloat scale = [CCDirector sharedDirector].contentScaleFactor;
805+
CGFloat scale = [CCDirector sharedDirector].contentScaleFactor;
806806
UIFont* font = [UIFont fontWithName:_fontName size:_fontSize * scale];
807-
float shadowBlurRadius = _shadowBlurRadius * scale;
807+
CGFloat shadowBlurRadius = _shadowBlurRadius * scale;
808808
CGPoint shadowOffset = ccpMult(self.shadowOffsetInPoints, scale);
809-
float outlineWidth = _outlineWidth * scale;
809+
CGFloat outlineWidth = _outlineWidth * scale;
810810

811811
BOOL hasShadow = (_shadowColor.alpha > 0);
812812
BOOL hasOutline = (_outlineColor.alpha > 0 && _outlineWidth > 0);
813813

814-
float xOffset = 0;
815-
float yOffset = 0;
816-
float scaleFactor = 1;
814+
CGFloat xOffset = 0;
815+
CGFloat yOffset = 0;
816+
CGFloat scaleFactor = 1;
817817

818-
float xPadding = 0;
819-
float yPadding = 0;
820-
float wDrawArea = 0;
821-
float hDrawArea = 0;
818+
CGFloat xPadding = 0;
819+
CGFloat yPadding = 0;
820+
CGFloat wDrawArea = 0;
821+
CGFloat hDrawArea = 0;
822822

823823
CGSize originalDimensions = _dimensions;
824824
originalDimensions.width *= scale;
@@ -866,12 +866,12 @@ - (CCTexture*) createTextureWithString:(NSString*) string useFullColor:(BOOL)use
866866
// Handle strings with fixed dimensions
867867
if (_adjustsFontSizeToFit)
868868
{
869-
float fontSize = font.pointSize;
869+
CGFloat fontSize = font.pointSize;
870870
CGSize wantedSizeFirstLine = [string sizeWithFont:font];
871871
CGSize wantedSize = [string sizeWithFont:font constrainedToSize:CGSizeMake(wantedSizeFirstLine.width, 1024) lineBreakMode:0];
872872

873-
float wScaleFactor = 1;
874-
float hScaleFactor = 1;
873+
CGFloat wScaleFactor = 1;
874+
CGFloat hScaleFactor = 1;
875875
if (wantedSize.width > wDrawArea)
876876
{
877877
wScaleFactor = wDrawArea/wantedSize.width;
@@ -886,8 +886,8 @@ - (CCTexture*) createTextureWithString:(NSString*) string useFullColor:(BOOL)use
886886

887887
if (scaleFactor != 1)
888888
{
889-
float newFontSize = fontSize * scaleFactor;
890-
float minFontSize = _minimumFontSize * scale;
889+
CGFloat newFontSize = fontSize * scaleFactor;
890+
CGFloat minFontSize = _minimumFontSize * scale;
891891
if (minFontSize && newFontSize < minFontSize) newFontSize = minFontSize;
892892
font = [UIFont fontWithName:font.fontName size:newFontSize];
893893
}

cocos2d/CCPhysicsNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Mass has no particular units. I personally find it intuitive to use 1.0 as the m
242242
* @param radius Radius to sweep.
243243
* @param block Block to execute per result.
244244
*/
245-
-(void)pointQueryAt:(CGPoint)point within:(CGFloat)radius block:(BOOL (^)(CCPhysicsShape *shape, CGPoint nearest, CGFloat distance))block;
245+
-(void)pointQueryAt:(CGPoint)point within:(CGFloat)radius block:(void (^)(CCPhysicsShape *shape, CGPoint nearest, CGFloat distance))block;
246246

247247
/**
248248
* Shoot a ray from 'start' to 'end' and find all of the CCPhysicsShapes that it would hit.
@@ -252,7 +252,7 @@ Mass has no particular units. I personally find it intuitive to use 1.0 as the m
252252
* @param end End point.
253253
* @param block Block to execute per result.
254254
*/
255-
-(void)rayQueryFirstFrom:(CGPoint)start to:(CGPoint)end block:(BOOL (^)(CCPhysicsShape *shape, CGPoint point, CGPoint normal, CGFloat distance))block;
255+
-(void)rayQueryFirstFrom:(CGPoint)start to:(CGPoint)end block:(void (^)(CCPhysicsShape *shape, CGPoint point, CGPoint normal, CGFloat distance))block;
256256

257257
/**
258258
* Find all CCPhysicsShapes whose bounding boxes overlap the given CGRect.
@@ -261,7 +261,7 @@ Mass has no particular units. I personally find it intuitive to use 1.0 as the m
261261
* @param rect Rectangle area to check.
262262
* @param block The block is called once for each shape found.
263263
*/
264-
-(void)rectQuery:(CGRect)rect block:(BOOL (^)(CCPhysicsShape *shape))block;
264+
-(void)rectQuery:(CGRect)rect block:(void (^)(CCPhysicsShape *shape))block;
265265

266266
@end
267267

cocos2d/CCPhysicsNode.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,21 +377,21 @@ -(void)setCollisionDelegate:(NSObject<CCPhysicsCollisionDelegate> *)collisionDel
377377

378378
//MARK: Queries:
379379

380-
-(void)pointQueryAt:(CGPoint)point within:(CGFloat)radius block:(BOOL (^)(CCPhysicsShape *, CGPoint, CGFloat))block
380+
-(void)pointQueryAt:(CGPoint)point within:(CGFloat)radius block:(void (^)(CCPhysicsShape *, CGPoint, CGFloat))block
381381
{
382382
cpSpacePointQuery_b(_space.space, CCP_TO_CPV(point), radius, CP_SHAPE_FILTER_ALL, ^(cpShape *shape, cpVect p, cpFloat d, cpVect g){
383383
block([cpShapeGetUserData(shape) userData], CPV_TO_CCP(p), d);
384384
});
385385
}
386386

387-
-(void)rayQueryFirstFrom:(CGPoint)start to:(CGPoint)end block:(BOOL (^)(CCPhysicsShape *, CGPoint, CGPoint, CGFloat))block
387+
-(void)rayQueryFirstFrom:(CGPoint)start to:(CGPoint)end block:(void (^)(CCPhysicsShape *, CGPoint, CGPoint, CGFloat))block
388388
{
389389
cpSpaceSegmentQuery_b(_space.space, CCP_TO_CPV(start), CCP_TO_CPV(end), 0.0, CP_SHAPE_FILTER_ALL, ^(cpShape *shape, cpVect p, cpVect n, cpFloat t){
390390
block([cpShapeGetUserData(shape) userData], CPV_TO_CCP(p), CPV_TO_CCP(n), t);
391391
});
392392
}
393393

394-
-(void)rectQuery:(CGRect)rect block:(BOOL (^)(CCPhysicsShape *shape))block
394+
-(void)rectQuery:(CGRect)rect block:(void (^)(CCPhysicsShape *shape))block
395395
{
396396
cpBB bb = cpBBNew(
397397
CGRectGetMinX(rect),

cocos2d/CCTiledMapLayer.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ -(id) initWithTilesetInfo:(CCTiledMapTilesetInfo*)tilesetInfo layerInfo:(CCTiled
117117
_mapTileSize = mapInfo.tileSize;
118118
_layerOrientation = mapInfo.orientation;
119119

120-
CGFloat pixelsToPoints = 1.0/tex.contentScale;
120+
CGFloat pixelsToPoints = tex ? 1.0/tex.contentScale : 1.0;
121121

122122
// offset (after layer orientation is set);
123123
CGPoint offset = [self calculateLayerOffset:layerInfo.offset];

cocos2d/Support/CCColor.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,14 @@ - (CCColor*) initWithUIColor:(UIColor *)color
170170
}
171171
#endif
172172

173+
/// After using you must call CGColorRelease(color)
173174
- (CGColorRef) CGColor
174175
{
175176
CGFloat components[4] = {(CGFloat)_r, (CGFloat)_g, (CGFloat)_b, (CGFloat)_a};
176-
return CGColorCreate(CGColorSpaceCreateDeviceRGB(), components);
177+
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
178+
CGColorRef color = CGColorCreate(colorspace, components);
179+
CGColorSpaceRelease(colorspace);
180+
return color;
177181
}
178182

179183
#ifdef __CC_PLATFORM_IOS

0 commit comments

Comments
 (0)