开发者

Targeting all subclassed CCSprites (cocos2d)

I'm working on a method to end the level, but to do so, I have to see that all of the enemy character h开发者_JS百科ave been killed. If my enemies are CCSprites, how do I make a method that detects if all of them are dead? I'm tracking their health with an int called enemyHp. For example, this is an if statement I made to remove the enemy if (enemy.enemyHp <= 0) {

To recap - I want to make a method that detects when all enemies have been killed.

Thanks


You would have to add those sprites to an array (NSArray) and then loop through that array.

for(Enemy * enemy in enemies)
{
  if (enemy.enemyHp <= 0) {    
    //kill it
  }  
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜