This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MyLayer | |
-(id) init { | |
if(self = [super init]) { | |
self.touchMode = kCCTouchesOneByOne; | |
self.touchEnabled = YES; | |
} | |
return self; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the tags | |
#define CLOUDS_TAG 1 | |
// Load node hierarchy from CocosBuilder file | |
CCNode *background = [CCBReader nodeGraphFromFile:@"background.ccbi"]; | |
// Recursively find node by tag | |
CCNode *clouds = [background getChildByTagRecursive:CLOUDS_TAG]; | |
// Do stuff with the node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface CCNode (getChildByTagRecursive) | |
-(CCNode*) getChildByTagRecursive:(int) tag; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Right after successful authentication | |
[[AchievementManager sharedManager] loadAchievements]; | |
// When achieving a one-shot achievement, such as "Get 3 stars at first try", set progress to 100% | |
[[AchievementManager sharedManager] reportAchievementIdentifier:@"achievement.3starsAtFirstTry" percentComplete:100]; | |
// When finishing a level, increment progress of "100 levels done" achievement by 1% | |
[[AchievementManager sharedManager] incrementAchievementIdentifier:@"achievement.100levels" percentIncrement:1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface AchievementManager : NSObject | |
+(AchievementManager*) sharedManager; | |
/** Local copy of current achievements progress */ | |
@property(nonatomic, retain) NSMutableDictionary *achievementsDictionary; | |
/** Must be called right after Game Center authentication */ | |
-(void) loadAchievements; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCMenuItemSprite *item = [CCMenuItemSprite | |
itemWithNormalSprite: [CCSprite spriteWithSpriteFrameName:@"sprite_normal.png"] | |
selectedSprite: [CCSprite spriteWithSpriteFrameName:@"sprite_selected.png"] | |
]; | |
// ... | |
[item selectedFor:0.2]; // highlight sprite for 0.2 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation CCMenuItem (SelectedFor) | |
-(void) selectedFor:(ccTime)duration { | |
if ([self isSelected]) return; | |
[self selected]; | |
[self runAction: [CCSequence | |
actionOne: [CCDelayTime actionWithDuration:duration] | |
two: [CCCallFunc actionWithTarget:self selector:@selector(unselected) ] | |
]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface CCMenuItem (SelectedFor) | |
-(void) selectedFor:(ccTime)duration; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myLayerColor.blendFunc = (ccBlendFunc) { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCSprite *mask = [CCSprite spriteWithFile:@"mask.png"]; | |
mask.blendFunc = (ccBlendFunc) { GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA }; | |
[scene addChild: mask]; |