how to make margin
in my app i want to move objects (from touch using the code below) inside the red rectangle how to make this
code :
UITouch *touch = [[event allTouches] anyOb开发者_如何学编程ject];
CGPoint location = [touch locationInView:[touch view]];
if (insidethepaddle) {
object1.center = CGPointMake(location.x, location.y - 50);
}
Just use CGRectContainsPoint(CGRect rect, CGPoint point)
or NSPointInRect(NSPoint aPoint, NSRect aRect)
to test if the center is still inside, otherwise just don't update the objects center
.
The specified CGRect
/NSRect
represents the frame of the red rectangle.
精彩评论