如何检测物体周围的自由空间
我的视图中几乎没有对象,我想检测空间(例如 [myObject frame] - 5px
)是否空闲。
现在我必须检测何时单击我的对象,但如何检测可用空间?
NSString *currPuzzle = [NSString stringWithFormat:@"%d", currentPuzzle];
currentObject = [puzzleArray objectForKey:currPuzzle];
currentObjectFrame = [currentObject frame];
currentObjectCenter = [currentObject center];
int left = currentObjectFrame.origin.x - 1;
int right = currentObjectFrame.origin.x + 1;
int top = currentObjectFrame.origin.y - 1;
int bottom = currentObjectFrame.origin.y + 1;
我不知道如何解决它。
有什么想法吗?
i've got few objects in view and i want to detect if space (for ex. [myObject frame] - 5px
) is free.
now i must detect when my object is clicked but how can i detect free space?
NSString *currPuzzle = [NSString stringWithFormat:@"%d", currentPuzzle];
currentObject = [puzzleArray objectForKey:currPuzzle];
currentObjectFrame = [currentObject frame];
currentObjectCenter = [currentObject center];
int left = currentObjectFrame.origin.x - 1;
int right = currentObjectFrame.origin.x + 1;
int top = currentObjectFrame.origin.y - 1;
int bottom = currentObjectFrame.origin.y + 1;
i've got no idea how solve it.
any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我解决了。我创建临时矩形并检测与该矩形的相交。一切都很好。
ok i resolve it. i create temporary rectangle and i detect intersect with this rect. all work great.