diff --git a/cocos2d/CCProgressNode.h b/cocos2d/CCProgressNode.h index 438fc288dc2..9e8c4764fc2 100644 --- a/cocos2d/CCProgressNode.h +++ b/cocos2d/CCProgressNode.h @@ -98,6 +98,9 @@ typedef NS_ENUM(NSUInteger, CCProgressNodeType) { /** Progress start position. */ @property (nonatomic, readwrite) CGPoint midpoint; +/** Radial Reverse Direction */ +@property (nonatomic, readwrite) BOOL reverseRadial; + /// ----------------------------------------------------------------------- /// @name Animating the Progress Node /// ----------------------------------------------------------------------- diff --git a/cocos2d/CCProgressNode.m b/cocos2d/CCProgressNode.m index 2f317d64be2..1635386de27 100644 --- a/cocos2d/CCProgressNode.m +++ b/cocos2d/CCProgressNode.m @@ -57,6 +57,7 @@ @implementation CCProgressNode { @synthesize sprite = _sprite; @synthesize type = _type; @synthesize reverseDirection = _reverseDirection; +@synthesize reverseRadial = _reverseRadial; @synthesize midpoint = _midpoint; @synthesize barChangeRate = _barChangeRate; @@ -76,6 +77,7 @@ -(id)initWithSprite:(CCSprite*) sprite if(( self = [super init] )){ _type = CCProgressNodeTypeRadial; _reverseDirection = NO; + _reverseRadial = NO; _percentage = 0.f; _verts = NULL; _vertexCount = 0; @@ -146,6 +148,15 @@ -(void)setReverseDirection:(BOOL)reverse } } +-(void)setReverseRadial:(BOOL)counterClockWise { + if(_reverseRadial != counterClockWise) { + _reverseRadial = counterClockWise; + + _dirtyVertexData = YES; + _needsUpdateProgress = YES; + } +} + -(void)setColor:(CCColor*)c { _sprite.color = c; @@ -259,10 +270,15 @@ -(void)setMidpoint:(CGPoint)midPoint } static inline CGPoint -BoundryTexCoord(int index) +BoundryTexCoord(int index, bool reverse) { - static const CGPoint points[] = {{1,1}, {1,0}, {0,0}, {0,1}}; - return points[index]; + if (!reverse) { + static const CGPoint points[] = {{1,1}, {1,0}, {0,0}, {0,1}}; + return points[index]; + } else { + static const CGPoint points[] = {{0,1}, {0,0}, {1,0}, {1,1}}; + return points[index]; + } } /// @@ -283,6 +299,7 @@ -(void)updateRadial float alpha = _percentage / 100.f; float angle = 2.f*((float)M_PI) * ( _reverseDirection == YES ? alpha : 1.f - alpha); + angle *= (_reverseRadial == YES) ? -1.f : 1.f; // We find the vector to do a hit detection based on the percentage // We know the first vector is the one @ 12 o'clock (top,mid) so we rotate @@ -314,8 +331,8 @@ -(void)updateRadial for (int i = 0; i <= 4; ++i) { int pIndex = (i + 3)%4; - CGPoint edgePtA = BoundryTexCoord(i % 4); - CGPoint edgePtB = BoundryTexCoord(pIndex); + CGPoint edgePtA = BoundryTexCoord(i % 4, _reverseRadial); + CGPoint edgePtB = BoundryTexCoord(pIndex, _reverseRadial); // Remember that the top edge is split in half for the 12 o'clock position // Let's deal with that here by finding the correct endpoints @@ -385,7 +402,7 @@ -(void)updateRadial _verts[1].position = [self vertexFromAlphaPoint:topMid]; for(int i = 0; i < index; ++i){ - CGPoint alphaPoint = BoundryTexCoord(i); + CGPoint alphaPoint = BoundryTexCoord(i, _reverseRadial); _verts[i+2].texCoord1 = [self textureCoordFromAlphaPoint:alphaPoint]; _verts[i+2].position = [self vertexFromAlphaPoint:alphaPoint]; } diff --git a/cocos2d/Support/CCFileUtils.h b/cocos2d/Support/CCFileUtils.h index 1d82620881f..a945fb2f498 100644 --- a/cocos2d/Support/CCFileUtils.h +++ b/cocos2d/Support/CCFileUtils.h @@ -36,6 +36,8 @@ extern NSString * const CCFileUtilsSuffixiPhone; extern NSString * const CCFileUtilsSuffixiPhoneHD; extern NSString * const CCFileUtilsSuffixiPhone5; extern NSString * const CCFileUtilsSuffixiPhone5HD; +extern NSString * const CCFileUtilsSuffixiPhone6Plus; +extern NSString * const CCFileUtilsSuffixiPhone6PlusHD; extern NSString * const CCFileUtilsSuffixMac; extern NSString * const CCFileUtilsSuffixMacHD; diff --git a/cocos2d/Support/CCFileUtils.m b/cocos2d/Support/CCFileUtils.m index 626c323917d..ae04eaddd64 100644 --- a/cocos2d/Support/CCFileUtils.m +++ b/cocos2d/Support/CCFileUtils.m @@ -39,6 +39,8 @@ NSString * const CCFileUtilsSuffixiPhoneHD = @"iphonehd"; NSString * const CCFileUtilsSuffixiPhone5 = @"iphone5"; NSString * const CCFileUtilsSuffixiPhone5HD = @"iphone5hd"; +NSString * const CCFileUtilsSuffixiPhone6Plus = @"iphone6plus"; +NSString * const CCFileUtilsSuffixiPhone6PlusHD = @"iphone6plushd"; NSString * const CCFileUtilsSuffixMac = @"mac"; NSString * const CCFileUtilsSuffixMacHD = @"machd"; NSString * const CCFileUtilsSuffix2x = @"2x"; @@ -163,6 +165,8 @@ -(id) init @"-hd", CCFileUtilsSuffixiPhoneHD, @"-iphone5", CCFileUtilsSuffixiPhone5, @"-iphone5hd", CCFileUtilsSuffixiPhone5HD, + @"-iphone6plus", CCFileUtilsSuffixiPhone6Plus, + @"-iphone6plushd", CCFileUtilsSuffixiPhone6PlusHD, @"", CCFileUtilsSuffixDefault, nil]; @@ -173,6 +177,8 @@ -(id) init @"resources-iphonehd", CCFileUtilsSuffixiPhoneHD, @"resources-iphone5", CCFileUtilsSuffixiPhone5, @"resources-iphone5hd", CCFileUtilsSuffixiPhone5HD, + @"resources-iphone6plus", CCFileUtilsSuffixiPhone6Plus, + @"resources-iphone6plushd", CCFileUtilsSuffixiPhone6PlusHD, @"", CCFileUtilsSuffixDefault, nil]; @@ -223,6 +229,8 @@ - (void) buildSearchResolutionsOrder [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPadHD]; [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPad]; if( _enableiPhoneResourcesOniPad ) { + [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPhone6PlusHD]; + [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPhone6Plus]; [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPhone5HD]; [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPhoneHD]; } @@ -240,6 +248,8 @@ - (void) buildSearchResolutionsOrder { // Terrible, terrible iPhone 6+ hack. [self setiPadContentScaleFactor:2.0]; + [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPhone6PlusHD]; + [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPhone6Plus]; [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPadHD]; [_searchResolutionsOrder addObject:CCFileUtilsSuffixiPhone5HD]; @@ -413,6 +423,10 @@ -(CGFloat) contentScaleForKey:(NSString*)k inDictionary:(NSDictionary *)dictiona return 1.0*_iPhoneContentScaleFactor; if( [key isEqualToString:CCFileUtilsSuffixiPhone5HD] ) return 2.0*_iPhoneContentScaleFactor; + if( [key isEqualToString:CCFileUtilsSuffixiPhone6PlusHD] ) + return 2.0*_iPadContentScaleFactor; + if( [key isEqualToString:CCFileUtilsSuffixiPhone6Plus] ) + return 1.0*_iPadContentScaleFactor; if( [key isEqualToString:CCFileUtilsSuffixDefault] ) return 1.0; #elif __CC_PLATFORM_MAC