如何获取龙骨的宽高

直接上代码:

    private dbTest() {
        let factory = dragonBones.EgretFactory.factory;
        let skeData = RES.getRes("Dragon_ske_json");
        let textureData = RES.getRes("Dragon_tex_png");
        let textureJson = RES.getRes("Dragon_tex_json");
        factory.parseDragonBonesData(skeData);
        factory.parseTextureAtlasData(textureJson, textureData);
        let armature = factory.buildArmature("Dragon", "Dragon");
        factory.clock.add(armature);
        armature.display.x = this.stage.stageWidth / 2;
        armature.display.y = this.stage.stageHeight / 2;
        armature.animation.play("walk", 0);

        let rect = new egret.Rectangle();

        let shape = new egret.Shape();
        shape.x = this.stage.stageWidth / 2;
        shape.y = this.stage.stageHeight / 2;
        this.addChild(shape);
        this.addChild(armature.display);
        egret.startTick(() => {
            let display = (armature.display as dragonBones.EgretArmatureDisplay)
            display.getBounds(rect);
            let width = display.width;
            let height = display.height
            console.log(`宽度为 :${width} 高度为:${height}`)

            let graphics = shape.graphics;
            graphics.clear();
            graphics.beginFill(0xff0000, 1);
            graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
            graphics.endFill();

            return false;
        }, this);
    }

你可能感兴趣的:(如何获取龙骨的宽高)