开发者

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

how to make margin

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜