//WEB环境下没有问题,安卓,苹果,windows等原生平台均会发生第二种使用方式出现的问题。
//第一种使用方式---多次使用,没有问题。
let dragonOfChildNode = this.node.getChildByName("Dragon_ske");
let dragonOfChildArmatureDisplay = dragonOfChildNode.getComponent(dragonBones.ArmatureDisplay);
dragonOfChildArmatureDisplay.playAnimation("walk", 10);
//第二种使用方式---在多次instantiate后,会发生ArmatureDisplay为null的情况,导致程序崩溃或者动画不播放,没有ArmatureData;
let dragonOfPrefabNode = cc.instantiate(this.dragonPrefab);
dragonOfPrefabNode.x = 150;
this.node.addChild(dragonOfPrefabNode);
let dragonOfPrefabArmatureDisplay = dragonOfPrefabNode.getComponent(dragonBones.ArmatureDisplay);
dragonOfPrefabArmatureDisplay.playAnimation("jump", 10);
//原生报错位置
void BaseObject::_returnObject(BaseObject* object)
{
const auto classTypeIndex = object->getClassTypeIndex();
const auto maxCountIterator = _maxCountMap.find(classTypeIndex);
const auto maxCount = maxCountIterator != _maxCountMap.end() ? maxCountIterator->second : _defaultMaxCount;
auto& pool = _poolsMap[classTypeIndex];
if (pool.size() < maxCount)
{
if (std::find(pool.cbegin(), pool.cend(), object) == pool.cend())
{
pool.push_back(object);
}
else
{
DRAGONBONES_ASSERT(false, “The object aleady in pool.”);
}
object->_isInPool = true;
if (_recycleOrDestroyCallback != nullptr)
_recycleOrDestroyCallback(object, 0);
}
else
{
delete object;
}
}
测试项目地址[DragonBones](https://github.com/xiaoxinyougui/DragonBonesBugEx)
官方文档参考地址
[组件参考](https://docs.cocos.com/creator/manual/zh/components/dragonbones.html?q=dragon)
[骨骼动画资源](https://docs.cocos.com/creator/manual/zh/asset-workflow/dragonbones.html?h=dragon)