Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_NGT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
middleLayer_for_NGT
Commits
07252680
Commit
07252680
authored
Mar 07, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 中间层完美适配
parent
ba03f80e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
54 deletions
+46
-54
middleLayer_for_NGT.fire
assets/middleLayer_for_NGT/scene/middleLayer_for_NGT.fire
+0
-30
middleLayer.js
assets/middleLayer_for_NGT/script/middleLayer.js
+46
-24
No files found.
assets/middleLayer_for_NGT/scene/middleLayer_for_NGT.fire
View file @
07252680
...
@@ -311,9 +311,6 @@
...
@@ -311,9 +311,6 @@
},
},
{
{
"__id__": 94
"__id__": 94
},
{
"__id__": 95
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -3923,32 +3920,5 @@
...
@@ -3923,32 +3920,5 @@
"_isTrimmedMode": true,
"_isTrimmedMode": true,
"_atlas": null,
"_atlas": null,
"_id": "77Taml+DhKYLCnxnSi08Bm"
"_id": "77Taml+DhKYLCnxnSi08Bm"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1280,
"_originalHeight": 720,
"_id": "b8s6BwK6JGdo9khgpExHfg"
}
}
]
]
\ No newline at end of file
assets/middleLayer_for_NGT/script/middleLayer.js
View file @
07252680
...
@@ -80,7 +80,7 @@ cc.Class({
...
@@ -80,7 +80,7 @@ cc.Class({
start
()
{
start
()
{
initAir
(
this
);
initAir
(
this
);
this
.
reWriteAir
();
this
.
reWriteAir
();
this
.
update
Widgets
();
this
.
update
Scale
();
window
.
courseware
.
getEngineInfo
((
dataStr
)
=>
{
window
.
courseware
.
getEngineInfo
((
dataStr
)
=>
{
const
engineInfo
=
JSON
.
parse
(
dataStr
);
const
engineInfo
=
JSON
.
parse
(
dataStr
);
...
@@ -402,7 +402,7 @@ cc.Class({
...
@@ -402,7 +402,7 @@ cc.Class({
window
.
courseware
.
freeAllOcMethod
();
window
.
courseware
.
freeAllOcMethod
();
this
.
hideWaitingLetters
();
this
.
hideWaitingLetters
();
this
.
update
Widgets
();
this
.
update
Scale
();
callback
&&
callback
();
callback
&&
callback
();
});
});
});
});
...
@@ -425,34 +425,56 @@ cc.Class({
...
@@ -425,34 +425,56 @@ cc.Class({
this
.
loadBundleByConf
(
this
.
bundleInfoList
[
this
.
currentBundleIndex
]);
this
.
loadBundleByConf
(
this
.
bundleInfoList
[
this
.
currentBundleIndex
]);
},
},
updateWidgets
()
{
this
.
updateScale
();
this
.
node
.
getComponentsInChildren
(
cc
.
Widget
).
forEach
((
widget
)
=>
{
widget
.
updateAlignment
();
});
},
updateScale
()
{
updateScale
()
{
// const canvas = cc.find("Canvas");
console
.
log
(
"
updateScale
"
);
// const canvasSize = cc.view.getCanvasSize();
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
canvasComponent
=
canvas
.
getComponent
(
cc
.
Canvas
);
const
canvasSize
=
cc
.
view
.
getCanvasSize
();
const
designSize
=
cc
.
view
.
getDesignResolutionSize
();
if
(
canvasComponent
.
fitHeight
&&
canvasComponent
.
fitWidth
)
{
console
.
log
(
"
fit both
"
);
// const designSize = cc.view.getDesignResolutionSize();
const
scale
=
Math
.
max
(
designSize
.
width
/
canvasSize
.
width
,
designSize
.
height
/
canvasSize
.
height
);
// const scale =
this
.
node
.
width
=
canvasSize
.
width
;
// canvas.width / canvasSize.width / (canvas.height / canvasSize.height);
this
.
node
.
height
=
canvasSize
.
height
;
this
.
node
.
scale
=
scale
;
// console.log("canvasSize:", canvasSize);
const
pos
=
this
.
node
.
parent
.
convertToNodeSpaceAR
(
// console.log("designSize:", designSize);
canvas
.
convertToWorldSpaceAR
(
cc
.
v2
(
0
,
0
))
);
this
.
node
.
setPosition
(
pos
);
return
;
}
// console.log({ x: canvas.x, y: canvas.y });
if
(
canvasComponent
.
fitHeight
&&
!
canvasComponent
.
fitWidth
)
{
// console.log({ width: canvas.width, height: canvas.height });
console
.
log
(
"
fit height
"
);
// console.log('scale = ' + scale);
// this.node.width = canvas.width;
const
scale
=
designSize
.
height
/
canvasSize
.
height
;
// this.node.height = canvas.height * scale;
this
.
node
.
width
=
canvasSize
.
width
;
this
.
node
.
height
=
canvasSize
.
height
;
this
.
node
.
scale
=
scale
;
this
.
node
.
x
=
(
this
.
node
.
width
*
scale
)
/
2
;
this
.
node
.
y
=
(
this
.
node
.
height
*
scale
)
/
2
;
return
;
}
if
(
!
canvasComponent
.
fitHeight
&&
canvasComponent
.
fitWidth
)
{
console
.
log
(
"
fit width
"
);
// this.node.x = this.node.width / 2;
const
scale
=
designSize
.
width
/
canvasSize
.
width
;
// this.node.y = this.node.height / 2 - 120;
this
.
node
.
width
=
canvasSize
.
width
;
this
.
node
.
height
=
canvasSize
.
height
;
this
.
node
.
scale
=
scale
;
this
.
node
.
x
=
(
this
.
node
.
width
*
scale
)
/
2
;
this
.
node
.
y
=
(
this
.
node
.
height
*
scale
)
/
2
;
return
;
}
},
},
exit
()
{
exit
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment