加入内容适配方面内容

This commit is contained in:
caizhitao
2019-02-24 22:04:59 +08:00
parent 15bc438fae
commit 32b675cb6f
7 changed files with 32 additions and 29 deletions

View File

@@ -47,8 +47,8 @@ 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);
// // 3. 因为本节点的宽高发生了改变,所以要手动更新剩下子节点的宽高
// this._updateAllChildNodeWidget(this.node);
// if (CC_DEBUG) {
// cc.log(`节点在SHOW_ALL模式下展示的宽高: ${realWidth} x ${realHeight}`);
@@ -61,19 +61,19 @@ 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);
});
}
// 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);
// });
// }
}

View File

@@ -1,5 +1,8 @@
const { ccclass, property } = cc._decorator;
/**
* 未完成
*/
@ccclass
export default class MultiResolutionCompat extends cc.Component {
static DEFAULT_RESOLUTION_WIDTH = 720;