Exemplo n.º 1
0
void BattleScene::tick() {
    CCArray* pets = troop->check();
    if (pets->count() > 0) {
        int c = pets->count(), i = 0;
        for (; i < c; i++) {
            Spell* spell = new Spell(NULL);
            spells->addObject(spell);
            addChild(spell->getSprite());
        }
    }
    
    CCArray* demons = enemy->check();
    
    int i = 0, c = spells->count();
    for (; i < c; i++) {
        Spell* spell = (Spell*)spells->objectAtIndex(i);

        if (spell->stopped()) {
            removeChild(spell->getSprite(), true);
            spells->removeObjectAtIndex(i);
            i--;
            c--;
        } else {
            spell->attack(demons);
        }
    }
    
    enemy->check();
}