My goal is to add a sprite, leftOn, to the screen after a user touches the screen.
Here's my code:
-(void)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector]convertToGL:location];
if (CGRectContainsPoint([leftOff boundingBox],location)) {
CCLOG(@"Left Pressed");
[self addChild:leftOn];
}
}
The Log always outputs "Left Pressed" but stops running without adding the sprite. If I add the sprite in the init method it does show. Also, I've tried changing the order of the sprite e.g., [self addChild:leftOn z:2], and it still does not display.