cocos2dx碰撞检测实现(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-06 08:43 点击:次
p> CCArray* targetsToDelete =new CCArray;
p> CCObject* it = NULL;
p> CCObject* jt = NULL;
p>
p> CCARRAY_FOREACH(_bullet, it)
p> {
p> CCSprite *projectile = dynamic_cast<CCSprite*>(it);
p> CCRect projectileRect = CCRectMake(
p> projectile->getPosition().x - (projectile->getContentSize().width/2),
p> projectile->getPosition().y - (projectile->getContentSize().height/2),
p> projectile->getContentSize().width,
p> projectile->getContentSize().height);
p>
p> CCARRAY_FOREACH(_target, jt)
p> {
p> CCSprite *target = dynamic_cast<CCSprite*>(jt);
p> CCRect targetRect = CCRectMake(
p> target->getPosition().x - (target->getContentSize().width/2),
p> target->getPosition().y - (target->getContentSize().height/2),
p> target->getContentSize().width,
p> target->getContentSize().height);
p>
p> if (projectileRect.intersectsRect(targetRect))
p> {
p> targetsToDelete->addObject(target);
p> projectilesToDelete->addObject(projectile);
p> }
p> }
p> }
p>
p> CCARRAY_FOREACH(targetsToDelete, jt)
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 进入详细评论页>>
您可能感兴趣的文章
- Cocos2d-x Render-NewCulling
- cocos2d 环境搭建 ios xocde
- cocos2d-x在iOS/Android双平台上嵌入WebView
- Cocos2d-x 自定义按钮类控制精灵攻击----之游戏开发
- cocos2d-x在win32和iOS、android下获取当前系统时间的
- cocos2d-x-3.0 alpha1与C++11练习九:飞镖忍者,添加发
- cocos3.0使用cocostudio动画帧结合地图对象键值创建
- cocos2d-x 2.0.3 设置高清模式注意事项(cocos2d-x 2.
- cocos2d-x 3.0 Loading界面实现
- 《BREW进阶与精通——3G移动增值业务的运营、定

![cocos2d_x+lua[2]](/uploads/allimg/131030/110J64609-0-lp.jpg)








