Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
Lwd
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
Lwd
Commits
b6cc7433
Commit
b6cc7433
authored
Mar 31, 2021
by
Lwd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aaaa
parent
a0fd46f2
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2624 additions
and
2389 deletions
+2624
-2389
Game.fire
play/assets/tmpGame/scene/Game.fire
+2568
-2380
view.js
play/assets/tmpGame/script/common/view.js
+56
-9
No files found.
play/assets/tmpGame/scene/Game.fire
View file @
b6cc7433
This diff is collapsed.
Click to expand it.
play/assets/tmpGame/script/common/view.js
View file @
b6cc7433
...
...
@@ -15,6 +15,18 @@ cc.Class({
type
:
cc
.
Widget
,
},
bgScaleMax
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
背景适配
"
},
nodeUIOffset
:
{
default
:
[],
type
:
cc
.
Node
,
displayName
:
"
节点偏移
"
},
canvasView
:
{
default
:
null
,
type
:
cc
.
Canvas
,
...
...
@@ -38,6 +50,8 @@ cc.Class({
this
.
setUIMax
(
this
.
MaxSize
);
this
.
settopUI
(
this
.
MaxSize
);
this
.
setBgScale
();
this
.
setUiPositon
();
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
...
...
@@ -47,15 +61,6 @@ cc.Class({
}
},
0
);
this
.
MaxSize
=
1
;
// if (window.addEventListener) {
// window.addEventListener('resize', scaleEventCallBack, false)
// } else if (window.attachEvent) {
// window.attachEvent('resize', scaleEventCallBack, false)
// };
// g.event_mgr.reg("adjustUI", () => {
// this.init();
// });
},
init
:
function
()
{
var
canvaSize
=
this
.
findCanvas
();
...
...
@@ -78,6 +83,8 @@ cc.Class({
g
.
data_mgr
.
MaxSize
=
this
.
MaxSize
;
this
.
setUIMax
(
this
.
MaxSize
);
this
.
settopUI
(
this
.
MaxSize
);
this
.
setBgScale
();
this
.
setUiPositon
();
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
for
(
var
i
in
list
)
{
...
...
@@ -86,6 +93,7 @@ cc.Class({
},
// //屏幕缩放事件
// scaleEventCallBack: function () {
// //setTimeout(function () {
...
...
@@ -114,6 +122,45 @@ cc.Class({
console
.
log
(
this
.
topUI
[
i
].
top
);
}
},
//背景适配
setBgScale
:
function
()
{
for
(
var
i
in
this
.
bgScaleMax
)
{
// 1. 先找到 SHOW_ALL 模式适配之后,本节点的实际宽高以及初始缩放值
let
scaleForShowAll
=
Math
.
min
(
cc
.
view
.
getCanvasSize
().
width
/
this
.
bgScaleMax
[
i
].
width
,
cc
.
view
.
getCanvasSize
().
height
/
this
.
bgScaleMax
[
i
].
height
);
let
realWidth
=
this
.
bgScaleMax
[
i
].
width
*
scaleForShowAll
;
let
realHeight
=
this
.
bgScaleMax
[
i
].
height
*
scaleForShowAll
;
// 2. 基于第一步的数据,再做缩放适配
this
.
bgScaleMax
[
i
].
scale
=
Math
.
max
(
cc
.
view
.
getCanvasSize
().
width
/
realWidth
,
cc
.
view
.
getCanvasSize
().
height
/
realHeight
);
}
},
//适配节点位置
setUiPositon
:
function
()
{
for
(
var
i
in
this
.
nodeUIOffset
)
{
// 1. 先找到 SHOW_ALL 模式适配之后,本节点的实际宽高以及初始缩放值
let
srcScaleForShowAll
=
Math
.
min
(
cc
.
view
.
getCanvasSize
().
width
/
this
.
nodeUIOffset
[
i
].
width
,
cc
.
view
.
getCanvasSize
().
height
/
this
.
nodeUIOffset
[
i
].
height
);
let
realWidth
=
this
.
nodeUIOffset
[
i
].
width
*
srcScaleForShowAll
;
let
realHeight
=
this
.
nodeUIOffset
[
i
].
height
*
srcScaleForShowAll
;
// 2. 基于第一步的数据,再做节点宽高重置
this
.
nodeUIOffset
[
i
].
width
=
this
.
nodeUIOffset
[
i
].
width
*
(
cc
.
view
.
getCanvasSize
().
width
/
realWidth
);
this
.
nodeUIOffset
[
i
].
height
=
this
.
nodeUIOffset
[
i
].
height
*
(
cc
.
view
.
getCanvasSize
().
height
/
realHeight
);
}
},
setUIMax
:
function
(
size
)
{
for
(
var
i
in
this
.
UIMax
)
{
if
(
this
.
UIMax
[
i
].
perScale
==
undefined
)
{
...
...
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