Reputation: 15
I'm new use Cocos2d. I have a problem show in picture link(sorry I could upload picture directly). how I can check red sprite position inside the black region?
http://postimg.org/image/86f6ol2mh/
Upvotes: 0
Views: 91
Reputation: 78
You can use LearnCocos2D sugestion or if you don't need exactly this shape maybe you can get by with radius from center of image.
- (BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
location = [self convertToNodeSpace:location];
float dist = pow(YOURSPRITE.position.x - location.x, 2) + pow(YOURSPRITE.position.y - location.y, 2);
dist = sqrt(dist);
if (dist <= 70) { //use some value for radius (70)
}
}
Upvotes: 1