cocos2d-x的碰撞检测

来源:互联网 发布:miui免费网络短信 编辑:程序博客网 时间:2024/05/05 03:53

在网上看到的是cgrect的方法

    CGRect projectileRect = CGRectMake(projectile.position.x ,    projectile.position.y ,   projectile.contentSize.width  ,    projectile.contentSize.height );            CGRect targetRect = CGRectMake(target.position.x ,    target.position.y ,  target.contentSize.width,    target.contentSize.height);        if (CGRectIntersectsRect(projectileRect, targetRect)) {        碰撞了.    }

自己用的ccrect的这个方法

CCRect hookstance=CCRectMake(hook->getPosition().x, hook->getPosition().y, hook->getContentSize().width, hook->getContentSize().height); CCRect shistance=CCRectMake(shi->getPosition().x,shi->getPosition().y, shi->getContentSize().width, shi->getContentSize().height);        if (hookstance.intersectsRect(shistance)){碰撞了}


0 0
原创粉丝点击