-(BOOL) ccTouchBegan:touch withEvent:event
{
CGPoint touchLocation = [touchlocationInView: [touchview]];
touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
CGPoint local = [item convertToNodeSpace:touchLocation];
CGRect r = [itemrect];
r.origin =CGPointZero;
if( CGRectContainsPoint( r, local ) )
//表示点中item
}
}cocos2d触摸点坐标转换标准写法
最新推荐文章于 2023-07-16 20:36:37 发布
本文介绍了一个简单的iOS触摸事件处理方法ccTouchBegan。通过该方法可以判断触摸是否发生在指定UI元素上。首先将触摸位置从视图坐标转换为GL坐标,再转换为节点空间坐标,最后检查该坐标是否位于元素的矩形范围内。
1万+

被折叠的 条评论
为什么被折叠?



