问个问题 求大神

我定义了个触摸监听器 获取touch坐标 加载精灵并使其在0,8s内move to 到touch 的坐标 为了让精灵到达后消失 写了个定时器函数scheduleOnce 0.8s后会remove精灵 但是如果我连续点击2下 就是在上一个精灵还没到达之前 即0.8s以内 再点击一下 上一个精灵的定时器函数好像就不会执行了 是新的touch事件中止了上一个的定时器函数吗? 求大神解决

bool HelloWorld::TouchBegan(Touch* touch,Event* event) {
    bullet_num++;
    log("touch!,%f %f %d",touch->getLocation().x,touch->getLocation().y,bullet_num);
    double angle = atan2(touch->getLocation().y,touch->getLocation().x);
    auto sprite1 = Sprite::create("bullet.jpg");
    sprite1->setTag(101);
    sprite1->setScale(0.25);
    sprite1->setPosition(Vec2::ZERO);
    sprite1->setRotation(-angle*180/M_PI);
    this->addChild(sprite1);
    auto move = MoveTo::create(0.8f,Vec2(touch->getLocation().x,touch->getLocation().y));
    sprite1->runAction(move);
    this->scheduleOnce(schedule_selector(HelloWorld::Remove),0.8f);
    return true;
}

void HelloWorld::Remove(float delay) {
    this->removeChildByTag(101);
    log("%d removed!",bullet_num);
}

```

那个bullet_num是我定义的static int 用来记录每个子弹的 比如我连续点击2 下 控制台里只会有2 removed!而不会有第一个remove

求解决~已经想了很久了

你连点两下,两个bullet的tag都是101, removeChildByTag的时候会有问题吧。你在HelloWorld::Remove(float delay)里面设置一个断点看看连点两下到底会跑几次,你那个bullet_num一点作用都没有,你点完第二下不管删除的是哪个bullet都只会log出2来啊。
有个不需要设置tag来删除的方法,不要用schedule,在runAction里面加一个callback的函数,在move完之后callback中删除掉子弹就好了