[Cocos Creator] 获取龙骨动画dragonbones精确外边框

引擎版本2.2.1

// TS
GetDragonbonesRect(dragonBones: dragonBones.ArmatureDisplay): cc.Rect {
    let rect = cc.rect(-50, -50, 100, 100);
    if (dragonBones) {
        let armature = dragonBones.armature();
        if (armature && armature.armatureData) {
            let aabb = armature.armatureData.aabb;
            if (aabb) {
                rect.x = aabb.x;
                rect.y = -(aabb.height + aabb.y);
                rect.width = aabb.width;
                rect.height = aabb.height;
            }
        }
    }
    return rect;
}

 

通过查看json文件获取

也可参考高版本编辑器方式

https://github.com/Jno1995/dragonBone-spine_Dome/tree/support_editor_v2.3.x

你可能感兴趣的:(TS,js,cocoscreator)