Cocos2d-x之塔防(二)让怪物跑起来(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-26 21:59 点击:次
主场景开启一个定时器,遍历所有的怪物,让怪物出现并跑起来
void GameScene::update( float dt ) { //==========enemy run================ vector坐标转换函数::iterator it=DataManage::getInstance()->v_enemy.begin(); while(it!=DataManage::getInstance()->v_enemy.end()) { if((*it)->iTurn >= (*it)->RoadCount-1) { (*it)->removeFromParentAndCleanup(true); it = DataManage::getInstance()->v_enemy.erase(it); }else { (*it)->run(); it++; } } //========enemy show time=================== vector ::iterator it_time=DataManage::getInstance()->v_time.begin(); while(it_time!=DataManage::getInstance()->v_time.end()) { float tmp = fabs(time-*it_time); if(( tmp>-0.0001) && (tmp < 0.0001)) { addEnemy(); it_time = DataManage::getInstance()->v_time.erase(it_time); }else { it_time++; } } time += 1.0/60; }
Point Tools::ConvertViewPoint( Point p ) { return Director::getInstance()->convertToGL(CCPoint(p.x * 60 + 30, p.y * 60)); }
看一下运行图
这一篇就到此为止了。
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>