龙骨的创建与销毁

龙骨

同一个项目可以包含多个骨架,比如 人开车,人和车都可以是单独的骨架

创建&&运用

  //读取一个骨骼数据,并创建实例显示到舞台
        var skeletonData = RES.getRes("skeleton_json");
        var textureData = RES.getRes("skeleton_tex_json");
        var texture = RES.getRes("skeleton_tex_png");
	//创建骨骼管理器
        var factory = new dragonBones.EgretFactory();
       //插入骨骼控制配置
	   factory.addDragonBonesData(dragonBones.DataParser.parseDragonBonesData(skeletonData));
	   //插入纹理集
        factory.addTextureAtlasData(factory.parseTextureAtlasData(textureData, texture));
	//读取骨架
        this.armature = factory.buildArmature("Robot");
		//读取显示对象
        this.armatureDisplay = this.armature.getDisplay();
		//骨骼计时器开始工作
        dragonBones.WorldClock.clock.add(this.armature);
        this.container.addChild(this.armatureDisplay);
        this.armatureDisplay.x = 0;
        this.armatureDisplay.y = 0;
        this.actionFlag = 0;
        //启动骨骼动画播放
        this.armature.animation.gotoAndPlay(this.actionArray[this.actionFlag]);

		egret.startTick(this.onTicker, this);
    private onTicker(timeStamp:number) {

        if(!this._time) {
            this._time = timeStamp;
        }

        var now = timeStamp;
        var pass = now - this._time;
        this._time = now;

        dragonBones.WorldClock.clock.advanceTime(pass / 1000);

        return false;
    }

参考 运用骨骼动画

销毁

this.armature.animation.stop();
        this.armature.dispose();
        this.removeChild(this.armature.display);
        egret.Ticker.getInstance().unregister(
            函数
        );
        dragonBones.WorldClock.clock.remove(this.armature);
        this.armature = null;

posted on 2018-04-14 18:02  老豆浆  阅读(808)  评论(0编辑  收藏  举报

导航