试了好久,所以上来求助各位,
先附上democc221spineDC.zip (920.5 KB)
使用下面的代码,
也就是点击 “直接产生:1个” 的时候,
可以看到spine合并drawcall的过程,一开始是20,然后会下降到10
for( let idx = 0; idx < 10; idx++ )
{
let node1 = new cc.Node();
node1.parent = _bas; //先产生在base,
node1.scale = 0.2;
node1.x = idx * 50;
let $sp1 = node1.addComponent( sp.Skeleton );
$sp1.skeletonData = skData1;
$sp1.setAnimation( 0, 'walk', true );
setTimeout( () =>
{
addToNodeInBoxBy( $sp1 );
$sp1.enableBatch = true;
$sp1.setAnimationCacheMode( sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE );
$sp1.setAnimation( 0, 'walk', true );
cc.log( `移动: ${ idx }` ); //定时移到_box, dc会因为spine合并而减少
}, idx * 500 );
}
但是,奇怪的事情发生了…
同样的逻辑,用两份spine就不行了…
我在 addToNodeInBoxBy 方法中,有依据SkeletonData的uuid去创建不同的node,
确保相同贴图的spine是放在同一个node中的,但是drawcall依然无法合并
for( let idx = 0; idx < 10; idx++ )
{
let node1 = new cc.Node();
node1.parent = _bas; //先产生在base,
node1.scale = 0.2;
node1.x = idx * 50;
let $sp1 = node1.addComponent( sp.Skeleton );
$sp1.skeletonData = skData1;
$sp1.setAnimation( 0, 'walk', true );
let node2 = new cc.Node();
node2.parent = _bas; //先产生在base,
node2.scale = 0.2;
node2.x = idx * 50;
node2.y = 35;
let $sp2 = node2.addComponent( sp.Skeleton );
$sp2.skeletonData = skData2;
$sp2.setAnimation( 0, 'walk', true );
setTimeout( () =>
{
addToNodeInBoxBy( $sp1 );
$sp1.enableBatch = true;
$sp1.setAnimationCacheMode( sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE );
$sp1.setAnimation( 0, 'walk', true );
addToNodeInBoxBy( $sp2 );
$sp2.enableBatch = true;
$sp2.setAnimationCacheMode( sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE );
$sp2.setAnimation( 0, 'walk', true );
cc.log( `移动: ${ idx }` ); //定时移到_box, dc会因为spine合并而减少
}, idx * 500 );
}
请教引擎组的各位大神,以及各位高手,
如何使用spine的正确合并drawcall的方式,感激不尽









