美文网首页
如何获取龙骨的宽高

如何获取龙骨的宽高

作者: 倩倩psyche | 来源:发表于2021-03-15 15:02 被阅读0次

    直接上代码:

        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);
        }
    

    相关文章

      网友评论

          本文标题:如何获取龙骨的宽高

          本文链接:https://www.haomeiwen.com/subject/ydukcltx.html