Cocos2D TouchesEnded not allowing me to access sprites?
- by maiko
Hey Guys! Thanks so much for reading!
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint location = [[CCDirector sharedDirector] convertToGL: [touch locationInView:touch.view]];
CGRect myRect = CGRectMake(100, 120, 75, 113);
int tjx = sprite.position.x;
if(CGRectContainsPoint(myRect, location)) {
tjx ++;
}
}
For some reason, ccTouchesEnded isn't allowing me to access my "sprite". I also tried to use
CGRectMake like so :
CGRectMake( sprite.position.x, sprite.position.y, sprite.contentSize.Width, sprite.contentSize.Height)
But I couldn't access my sprites position or height. I keep getting "sprite" undeclared when it is declared in the init method, and added to the child.
Please help!! I'm sure i'm missing something really simple here.