我在使用引擎过程中,看到log会偶尔打出
“ warning: you CANNOT change update priority in scheduled function”
这样的警告。。
请问是什么操作会导致这种情况出现呢?使用的版本是cocos2d-js-v3.0-rc0
看了下代码:
void Scheduler::schedulePerFrame(const ccSchedulerFunc& callback, void *target, int priority, bool paused)
{
tHashUpdateEntry *hashElement = nullptr;
HASH_FIND_PTR(_hashForUpdates, &target, hashElement);
if (hashElement)
{
// check if priority has changed
if ((*hashElement->list)->priority != priority)
{
if (_updateHashLocked)
{
CCLOG(“warning: you CANNOT change update priority in scheduled function”);
hashElement->entry->markedForDeletion = false;
hashElement->entry->paused = paused;
return;
}
else
{
// will be added again outside if (hashElement).
unscheduleUpdate(target);
}
}
else
{
hashElement->entry->markedForDeletion = false;
hashElement->entry->paused = paused;
return;
}
}
// most of the updates are going to be 0, that's way there
// is an special list for updates with priority 0
if (priority == 0)
{
appendIn(&_updates0List, callback, target, paused);
}
else if (priority < 0)
{
priorityIn(&_updatesNegList, callback, target, priority, paused);
}
else
{
// priority > 0
priorityIn(&_updatesPosList, callback, target, priority, paused);
}
}
貌似我没有修改过scheduler的优先级,为什么会报出这个警告呢?



