初步加入内容适配和贴边栏实现

This commit is contained in:
caizhitao
2019-01-31 15:54:20 +08:00
parent 65ff5881cc
commit db4e5db310
10 changed files with 2835 additions and 314 deletions

View File

@@ -45,6 +45,9 @@ export default class ContentAdapter extends cc.Component {
this.node.width = this.node.width * (cc.view.getCanvasSize().width / realWidth);
this.node.height = this.node.height * (cc.view.getCanvasSize().height / realHeight);
// 3. 因为本节点的宽高发生了改变,所以要手动更新剩下子节点的宽高
this._updateAllChildNodeWidget(this.node);
// if (CC_DEBUG) {
// cc.log(`节点在SHOW_ALL模式下展示的宽高: ${realWidth} x ${realHeight}`);
// cc.log(`节点在SHOW_ALL模式下展示的缩放: ${srcScaleForShowAll}`);
@@ -55,4 +58,20 @@ export default class ContentAdapter extends cc.Component {
// );
// }
}
private _updateAllChildNodeWidget(parentNode: cc.Node) {
if (parentNode == null) {
return;
}
let widget = parentNode.getComponent(cc.Widget);
if (widget != null) {
widget.updateAlignment();
}
if (parentNode.childrenCount == 0) {
return;
}
parentNode.children.forEach((childNode: cc.Node) => {
this._updateAllChildNodeWidget(childNode);
});
}
}