2012年9月3日

获取Sprite的实际Rect

摘要: 判断点击是否点击在了一个精灵上, 其实就是判断一个点是否在一个矩形内。cocos2d-x的2.0.2版本可以使用CCRect的函数bool CCRect::containsPoint(const CCPoint& point) const来判断。找出Sprite的Rect很重要了,简单搜索了下,发现网上普遍没有考虑Sprite的AnchorPoint, 所以导致判断出错。 1 CCSprite *sprite = CCSprite::create("test.png"); 2 3 CCSize s = sprite->getContentSize(); 4 C 阅读全文

posted @ 2012-09-03 00:07 young40 阅读(1469) 评论(0) 推荐(0)

导航