实现分析 - Enemy
来源:互联网 发布:ios和mac os区别 编辑:程序博客网 时间:2024/06/06 19:04
启动addEnemy的循环Listing 5.18 GameplayLayer.m init method additions[self schedule:@selector(addEnemy) interval:10.0f]; addEnemy 作为对外的入口 - 内部统一用 createObjectOfType 来处理 如果XXX (不再加入Enemy了),unschedule这个循环 Listing 5.17 GameplayLayer.m addEnemy method-(void)addEnemy {CGSize screenSize = [CCDirector sharedDirector].winSize; RadarDish *radarDish = (RadarDish*) [sceneSpriteBatchNode getChildByTag:kRadarDishTagValue];if (radarDish != nil) {if ([radarDish characterState] != kStateDead) { [self createObjectOfType:kEnemyTypeAlienRobot withHealth:100 atLocation:ccp(screenSize.width * 0.195f, screenSize.height * 0.1432f) withZValue:2]; } else { [self unschedule:@selector(addEnemy)]; } }}
下面是CreateObjectOfType的一部分
-(void)createObjectOfType:(GameObjectType)objectType withHealth:(int)initialHealth atLocation:(CGPoint)spawnLocation withZValue:(int)ZValue { if (kEnemyTypeRadarDish == objectType) { CCLOG(@"Creating the Radar Enemy"); RadarDish *radarDish = [[RadarDish alloc] initWithSpriteFrameName:@"radar_1.png"]; [radarDish setCharacterHealth:initialHealth]; [radarDish setPosition:spawnLocation]; [sceneSpriteBatchNode addChild:radarDish z:ZValue tag:kRadarDishTagValue]; [radarDish release]; } else if (kEnemyTypeAlienRobot == objectType) { CCLOG(@"Creating the Alien Robot"); EnemyRobot *enemyRobot = [[EnemyRobot alloc] initWithSpriteFrameName:@"an1_anim1.png"]; [enemyRobot setCharacterHealth:initialHealth]; [enemyRobot setPosition:spawnLocation]; [enemyRobot changeState:kStateSpawning]; [sceneSpriteBatchNode addChild:enemyRobot z:ZValue]; [enemyRobot setDelegate:self]; [enemyRobot release]; } else if (kEnemyTypeSpaceCargoShip == objectType) { ......
创建了enemy后,它的状态会是 kStateSpawning
- 实现分析 - Enemy part2
- 实现分析 - Enemy
- enemy 视野 实现
- enemy
- 7.Enemy
- [Java 游戏编程]STG类游戏的实现3-Enemy&&BulletCollision
- Know Your Enemy
- Sleeping with the Enemy
- know your enemy 主页
- Know Your Enemy
- Enemy at the Gateway
- Complexity is The Enemy
- HDU4536 XCOM Enemy Unknown
- XCOM Enemy Unknown
- Learning from the enemy
- Unity Enemy behaviour
- 【Codeforces61E】Enemy is weak
- HUST 1027 Enemy Target!
- Ruby简单的读写文件
- 数据库rac11.2.0.1升级到11.2.0.2遇到的问题(三)
- 排序算法---合并排序
- 用C写有面向对象特点的程序
- CIO如何获取内部信任资源?
- 实现分析 - Enemy
- rapidxml 使用手册2
- 全面解读WM_NOTIFY
- PopupWindow点击边框以外消失的方法
- 国外程序员推荐:每个程序员都应读的书
- 向SQL2005中导入.dbf文件中的数据
- file的getPath getAbsolutePath和getCanonicalPath的不同
- STL简介
- oracle下载位置统计