Handling input manually like in the previous recipe gives us the opportunity to manage touchable objects at a high level. Using an array of sprites sorted by Z order we can "swallow the input" so that background sprites aren't affected.
Execute the following code:
#import "ColorTouchSprite.h" @implementation Ch2_DepthTestingInput -(CCLayer*) runRecipe { //Init the ColorTouchSprites [self initSprites]; return self; } -(void) initSprites { sprites = [[NSMutableArray alloc] init]; //We add 10 randomly colored sprites for(int x=0; x<10; x++){ CCSprite *sprite = [ColorTouchSprite spriteWithFile:@"blank.png"]; /* CODE OMITTED */ } } /* Process touch events */ -(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView: [touch view]]; point = [...