今天碰到一个比较诡异的bug,在一些情况下,使用stopAction无法中途停止Sequence action。
下面这段代码中的DelayTime解开注释后,永远无法在test2中停止当前Sequence。
期望的输出为:
test1 done test2 done
实际输出为:
test1 done
test2 done
test3 done
m_testAction = this->runAction(Sequence::create(CallFunc::create(CC_CALLBACK_0(MainLayer::test1, this)),
// DelayTime::create(2),
CallFunc::create(CC_CALLBACK_0(MainLayer::test2, this)),
CallFunc::create(CC_CALLBACK_0(MainLayer::test3, this)),
NULL));
void MainLayer::test1()
{
cout << “test1 done” << endl;
}
void MainLayer::test2()
{
cout << “test2 done” << endl;
this->stopAction(m_testAction);
}
void MainLayer::test3()
{
cout << “test3 done” << endl;
}