Hello,
I am creating a CGPath to define an area in my game like this:
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 that I could just use another CGRect but the path I wish to actually create is not actually a Rectangle (I am just testing at the moment). And then detecting the touch area simply with a:
if (CGPathContainsPoint(myPath, nil, location, YES))
This all works fine, the problem is that the CGPath may be moving up to 40 times per second. How Can I move it without having to create a new one?. I know 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 release and create a new Path up to 40 times per second, which I think might have a performance penalty is this true?.
I would like to be able to move it just like I am currently moving some CGRects by simply setting the origin to a different value, is this possible with CGPath?.
Thank you.
-Oscar
EDIT: I forgot to mention I don't have a GraphicsContext as I am not drawing on a UIView.