0

在我的应用程序中,我想在红色矩形内移动对象(使用下面的代码通过触摸)如何做到这一点iphone屏幕

代码 :

UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:[touch view]];
if (insidethepaddle) {
    object1.center = CGPointMake(location.x, location.y - 50);
}
4

1 回答 1

0

只需使用CGRectContainsPoint(CGRect rect, CGPoint point)orNSPointInRect(NSPoint aPoint, NSRect aRect)测试中心是否仍在内部,否则不要更新对象center

指定的CGRect/NSRect表示红色矩形的边框。

于 2011-03-21T20:12:20.857 回答