Commit 5b5438f1 authored by 李维's avatar 李维

适配竖屏适配

parent 60b08e1f
This diff is collapsed.
...@@ -87,6 +87,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -87,6 +87,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
async initView() { async initView() {
const canvas = cc.find('Canvas');
const touchboard = cc.find('Canvas/touchboard'); const touchboard = cc.find('Canvas/touchboard');
const contant = cc.find('Canvas/touchboard/contant'); const contant = cc.find('Canvas/touchboard/contant');
const scale = touchboard.height / contant.height; const scale = touchboard.height / contant.height;
...@@ -95,6 +96,16 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -95,6 +96,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
contant.scale = scale; contant.scale = scale;
contant.x = contant.width / 2 - touchboard.width / 2; contant.x = contant.width / 2 - touchboard.width / 2;
if((canvas.width / canvas.height) >= 1) {
// 横屏
} else {
// 竖屏
const bg = cc.find('Canvas/touchboard/contant/bg');
bg.x = -1800;
bg.y = -150;
bg.scale = 0.3;
}
const bg = cc.find('Canvas/touchboard/contant/bg'); const bg = cc.find('Canvas/touchboard/contant/bg');
for (let i = 0; i < 36; i++) { for (let i = 0; i < 36; i++) {
const btn = seekChildByName(bg, `btn_${i}`); const btn = seekChildByName(bg, `btn_${i}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment