Games have many layers. The most common example is the main action layer (where the players and enemies are) having to communicate with the HUD layer (which presents score, health and other info) to the gamer. Let’s see how we can communicate between layers. Typically you create a Scene and then a Layer in order to add that Layer as a child to the Scene. Let’s say our Scene.h looks like this: #import <Foundation/Foundation.h> #import “cocos2d.h” @interface Scene1 : CCScene { } @end And our Scene.m looks like this: -(id)init { if ((self = [super init])) { Scene1ActionLayer * actionLayer = [[[Scene1ActionLayer alloc] init] autorelease]; [self addChild:actionLayer z:0 tag:kActionLayer]; }… Read More
Continue ReadingNSOperationQueue & NSInvocationOperation
1. In your main class’ init method call this: operationQueue = [[NSOperationQueue alloc]init]; [operationQueue setMaxConcurrentOperationCount:1]; 2. Then in your viewWillAppear you can call this: [self showLoadingIndicators]; //calls a method which presents loading indicators (optional) [self beginLoadingTwitterData]; // this is the method that fires it all off 3. In your beginLoadingTwitterData you call this: NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(synchronousLoadTwitterData) object:nil]; [operationQueue addOperation:operation]; // creates and adds NSOperation to a queue [operation release]; 4. In this synchronousLoadTwitterData is where you do the heavy lifting: NSDictionary *dict = [[NSDictionary alloc] initWithDictionary:[TwitterHelper fetchInfoForUsername:[twitterIds objectAtIndex:count]]] // this calls for a method “fetchInfoForUsername” which returns an NSDictionary, but to do so, it connects to… Read More
Continue ReadingWhat I want for xmas:” #Siri Create #Xc
What I want for xmas:” #Siri Create #Xcode project Tabbed Bar Application with #CoreData & #Storyboards. Create #NSManagedObject subclass.”
Continue Reading