DragonBones

来源:互联网 发布:网络管理(兼职) 编辑:程序博客网 时间:2024/06/04 22:17
我这边加载完资源以后,创建动画代码如下
this.dragonBonesSkeleData = dragonBones.DataParser.parseDragonBonesData(this.skeletonData);
        this.textureAtlas = new dragonBones.EgretTextureAtlas(this.textureData,this.jsonData);
        this.egretFactory = new dragonBones.EgretFactory();
        this.egretFactory.addDragonBonesData(this.dragonBonesSkeleData);
        this.egretFactory.addTextureAtlas(this.textureAtlas);

        var armatureName: string = this.skeletonData.armature[0].name;
        this.armture = this.egretFactory.buildArmature(armatureName);
        this.armtureDisplay = this.armture.display;
        dragonBones.WorldClock.clock.add(this.armture);
        this.addChild(this.armtureDisplay);


释放如下:
this.egretFactory.dispose();
this.textureAtlas.dispose();

this.dragonBonesSkeleData = null;

if(this.armtureDisplay.parent) this.armtureDisplay.parent.removeChild(this.armtureDisplay);
this.armtureDisplay = null;

this.armture.removeEventListener(dragonBones.AnimationEvent.COMPLETE,this.AnimationComp,this);
dragonBones.WorldClock.clock.remove(this.armture);
this.armture.animation.stop();
this.armture.dispose();
this.armture = null;



现在的问题是,升级到3.1.8以后,同样的动画,释放以后再创建就不显示了,把this.textureAtlas.dispose();去掉就好了
3.0.8下就是可以的

哪位帮忙看一下是不是代码有问题

如果不调dispose的话,内存会不会一直占用?因为有些动画不是一直有的,所以用完想释放掉

=====================================================================================

释放包含res 的释放 龙骨数据(在factory里)的释放 龙骨armature实例的释放 你的释放是完全正确的,现在龙骨内部会有对象池机制,所以回收后内存可能并不会下降,但是这并不会引起内存问题,因为内存的峰值始终是你需要的值,不比过多的担心,如果还有问题可以再详细了解,这样做的优势是,减小创建实例的开销,同时不会引起过多的垃圾回收 ...



0 0
原创粉丝点击