您的位置:首页 > 其它

在ccTouchesBegan 用;boundingBox 判断是不是在操作英雄

2013-11-15 14:10 239 查看
Cocos2d-x by Example Beginner's Guide,第3章

在GameLayer.ccp中

GameLayer::ccTouchBegan()中

for (int p = 0; p < 2; p++) {
player = (GameSprite *) _players->objectAtIndex(p);
if (player->boundingBox().containsPoint(tap)) {
player->setTouch(touch);
}
}

其中的boundingBox方法可以,确实玩家是否在操作英雄,见boundingBox()方法。

CCRect CCNode::boundingBox()
{
CCRect rect = CCRectMake(0, 0, m_obContentSize.width, m_obContentSize.height);
return CCRectApplyAffineTransform(rect, nodeToParentTransform());
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: