The best way to check the affected area, not just a rectangle

It's just interesting if there is another way to check the affected area using a polygon of a certain shape, and not just use CGRectMake.

Here is the same code for this example:

CGPoint location = [[Director sharedDirector] convertCoordinate: [touch locationInView: [touch view]]];
CGRect mySurface = CGRectMake(x, y, temp.contentSize.width, temp.contentSize.height);

if(CGRectContainsPoint(mySurface, location)) {
    // do something
    return kEventHandled;
}

Thought to have several CGRect objects in an if statement, but wondered if there is a better way to do this, for example, something like an image map in html for anchors.

+3
source share
2 answers

Consider CGPath:

Create a path; there are many GPath functions available. Then use:

Checks if a point is contained in the graphics path.

bool CGPathContainsPoint (
   CGPathRef path,
   const CGAffineTransform *m,
   CGPoint point,
   bool eoFill
);
+3
source

, Box2D Chipmunk, . cocos2D. , , , ... . , , , . , , , .

, : , ?!

0

Source: https://habr.com/ru/post/1717940/


All Articles