I create CGPathto define the area in my game as follows:
CGPathMoveToPoint ( myPath, NULL, center.x, center.y );
CGPathAddLineToPoint( myPath, NULL,center.x + 100, center.y);
CGPathAddLineToPoint( myPath, NULL, center.x + 100, center.y + 100);
CGPathAddLineToPoint( myPath, NULL, center.x, center.y + 100);
CGPathCloseSubpath ( myPath );
I know this is just a square, and I could just use a different one CGRect, but the path I want to create is not really a rectangle (I'm just testing now). And then detecting the touch area simply with:
if (CGPathContainsPoint(myPath, nil, location, YES))
Everything works fine, the problem is that it CGPathcan move up to 40 times per second. How can I move it without creating a new one? I know that I can do something like this to "move" it:
center.y += x;
CGPathRelease(myPath);
myPath = CGPathCreateMutable();
CGPathMoveToPoint ( myPath, NULL, center.x, center.y );
CGPathAddLineToPoint( myPath, NULL,center.x + 100, center.y);
CGPathAddLineToPoint( myPath, NULL, center.x + 100, center.y + 100);
CGPathAddLineToPoint( myPath, NULL, center.x, center.y + 100);
CGPathCloseSubpath ( myPath );
But I have to free and create a new path up to 40 times per second, which, I think, may have a performance limit; it's true?
, CGRects, , CGPath?
.
EDIT: , GraphicsContext, UIView.