Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NGT_02
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
NGT_02
Commits
9194fbdb
Commit
9194fbdb
authored
Feb 24, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
parent
396d96dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
184 deletions
+189
-184
_preDefine.js
assets/NGT_02/script/common/_preDefine.js
+1
-0
view.js
assets/NGT_02/script/common/view.js
+188
-184
No files found.
assets/NGT_02/script/common/_preDefine.js
View file @
9194fbdb
...
@@ -5,6 +5,7 @@ import { initResMgr_NGT_02 } from "../manager/res_mgr";
...
@@ -5,6 +5,7 @@ import { initResMgr_NGT_02 } from "../manager/res_mgr";
import
{
initSndMgr_NGT_02
}
from
"
../manager/snd_mgr
"
;
import
{
initSndMgr_NGT_02
}
from
"
../manager/snd_mgr
"
;
import
{
initUtils_NGT_02
}
from
"
./utils
"
;
import
{
initUtils_NGT_02
}
from
"
./utils
"
;
import
{
initEnumMgr_NGT_02
}
from
"
../game/speaker
"
;
import
{
initEnumMgr_NGT_02
}
from
"
../game/speaker
"
;
// 全局环境预声明
// 全局环境预声明
export
function
initGlobal_NGT_02
()
{
export
function
initGlobal_NGT_02
()
{
console
.
log
(
'
window.g init
'
);
console
.
log
(
'
window.g init
'
);
...
...
assets/NGT_02/script/common/view.js
View file @
9194fbdb
import
{
initGlobal_NGT_02
}
from
"
./_preDefine
"
;
/**
/**
* 适配
* 适配
*/
*/
...
@@ -8,7 +9,7 @@ cc.Class({
...
@@ -8,7 +9,7 @@ cc.Class({
UIMax
:
{
UIMax
:
{
default
:
[],
default
:
[],
type
:
cc
.
Node
,
type
:
cc
.
Node
,
displayName
:
"
等比放大
"
displayName
:
"
等比放大
"
,
},
},
topUI
:
{
topUI
:
{
default
:
[],
default
:
[],
...
@@ -18,26 +19,29 @@ cc.Class({
...
@@ -18,26 +19,29 @@ cc.Class({
bgScaleMax
:
{
bgScaleMax
:
{
default
:
[],
default
:
[],
type
:
cc
.
Node
,
type
:
cc
.
Node
,
displayName
:
"
背景适配
"
displayName
:
"
背景适配
"
,
},
},
nodeUIOffset
:
{
nodeUIOffset
:
{
default
:
[],
default
:
[],
type
:
cc
.
Node
,
type
:
cc
.
Node
,
displayName
:
"
节点偏移
"
displayName
:
"
节点偏移
"
,
},
},
canvasView
:
{
canvasView
:
{
default
:
null
,
default
:
null
,
type
:
cc
.
Canvas
,
type
:
cc
.
Canvas
,
displayName
:
"
根节点
"
displayName
:
"
根节点
"
,
},
},
isCanvas
:
{
isCanvas
:
{
default
:
false
,
default
:
false
,
}
},
},
},
onLoad
:
function
()
{
//开启适配
onLoad
:
function
()
{
initGlobal_NGT_02
();
//开启适配
this
.
widgetList
=
[];
this
.
widgetList
=
[];
this
.
scheduleOnce
(
function
()
{
this
.
scheduleOnce
(
function
()
{
...
@@ -45,8 +49,8 @@ cc.Class({
...
@@ -45,8 +49,8 @@ cc.Class({
this
.
init
();
this
.
init
();
}
else
{
}
else
{
var
canvaSize
=
this
.
findCanvas
();
var
canvaSize
=
this
.
findCanvas
();
var
w
=
(
canvaSize
.
width
)
/
720
;
var
w
=
canvaSize
.
width
/
720
;
var
h
=
(
canvaSize
.
height
)
/
1280
;
var
h
=
canvaSize
.
height
/
1280
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
this
.
setUIMax
(
this
.
MaxSize
);
this
.
setUIMax
(
this
.
MaxSize
);
...
@@ -55,7 +59,7 @@ cc.Class({
...
@@ -55,7 +59,7 @@ cc.Class({
this
.
setUiPositon
();
this
.
setUiPositon
();
var
scene
=
cc
.
director
.
getScene
();
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
);
for
(
var
i
in
list
)
{
for
(
var
i
in
list
)
{
list
[
i
].
updateAlignment
();
list
[
i
].
updateAlignment
();
}
}
...
@@ -85,8 +89,8 @@ cc.Class({
...
@@ -85,8 +89,8 @@ cc.Class({
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitHeight
=
true
;
this
.
canvasView
.
fitHeight
=
true
;
}
}
var
w
=
(
canvaSize
.
width
)
/
750
;
var
w
=
canvaSize
.
width
/
750
;
var
h
=
(
canvaSize
.
height
)
/
1334
;
var
h
=
canvaSize
.
height
/
1334
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
g
.
data_mgr
.
MaxSize
=
this
.
MaxSize
;
g
.
data_mgr
.
MaxSize
=
this
.
MaxSize
;
...
@@ -95,7 +99,7 @@ cc.Class({
...
@@ -95,7 +99,7 @@ cc.Class({
this
.
setBgScale
();
this
.
setBgScale
();
this
.
setUiPositon
();
this
.
setUiPositon
();
var
scene
=
cc
.
director
.
getScene
();
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
);
for
(
var
i
in
list
)
{
for
(
var
i
in
list
)
{
list
[
i
].
updateAlignment
();
list
[
i
].
updateAlignment
();
}
}
...
@@ -115,7 +119,6 @@ cc.Class({
...
@@ -115,7 +119,6 @@ cc.Class({
for
(
var
i
in
this
.
topUI
)
{
for
(
var
i
in
this
.
topUI
)
{
if
(
this
.
topUI
[
i
].
perTop
==
undefined
)
{
if
(
this
.
topUI
[
i
].
perTop
==
undefined
)
{
this
.
topUI
[
i
].
perTop
=
this
.
topUI
[
i
].
top
;
this
.
topUI
[
i
].
perTop
=
this
.
topUI
[
i
].
top
;
}
else
{
}
else
{
this
.
topUI
[
i
].
top
=
this
.
topUI
[
i
].
perTop
;
this
.
topUI
[
i
].
top
=
this
.
topUI
[
i
].
perTop
;
}
}
...
@@ -155,8 +158,10 @@ cc.Class({
...
@@ -155,8 +158,10 @@ cc.Class({
let
realHeight
=
720
*
srcScaleForShowAll
;
let
realHeight
=
720
*
srcScaleForShowAll
;
// 2. 基于第一步的数据,再做节点宽高重置
// 2. 基于第一步的数据,再做节点宽高重置
this
.
nodeUIOffset
[
i
].
width
=
1280
*
(
cc
.
view
.
getCanvasSize
().
width
/
realWidth
);
this
.
nodeUIOffset
[
i
].
width
=
this
.
nodeUIOffset
[
i
].
height
=
720
*
(
cc
.
view
.
getCanvasSize
().
height
/
realHeight
);
1280
*
(
cc
.
view
.
getCanvasSize
().
width
/
realWidth
);
this
.
nodeUIOffset
[
i
].
height
=
720
*
(
cc
.
view
.
getCanvasSize
().
height
/
realHeight
);
}
}
},
},
...
@@ -164,7 +169,6 @@ cc.Class({
...
@@ -164,7 +169,6 @@ cc.Class({
for
(
var
i
in
this
.
UIMax
)
{
for
(
var
i
in
this
.
UIMax
)
{
if
(
this
.
UIMax
[
i
].
perScale
==
undefined
)
{
if
(
this
.
UIMax
[
i
].
perScale
==
undefined
)
{
this
.
UIMax
[
i
].
perScale
=
this
.
UIMax
[
i
].
scaleX
;
this
.
UIMax
[
i
].
perScale
=
this
.
UIMax
[
i
].
scaleX
;
}
else
{
}
else
{
this
.
UIMax
[
i
].
scaleX
=
this
.
UIMax
[
i
].
perScale
;
this
.
UIMax
[
i
].
scaleX
=
this
.
UIMax
[
i
].
perScale
;
this
.
UIMax
[
i
].
scaleY
=
this
.
UIMax
[
i
].
perScale
;
this
.
UIMax
[
i
].
scaleY
=
this
.
UIMax
[
i
].
perScale
;
...
@@ -177,13 +181,13 @@ cc.Class({
...
@@ -177,13 +181,13 @@ cc.Class({
if
(
cc
.
sys
.
isNative
)
{
if
(
cc
.
sys
.
isNative
)
{
return
{
return
{
width
:
cc
.
view
.
getFrameSize
().
width
,
width
:
cc
.
view
.
getFrameSize
().
width
,
height
:
cc
.
view
.
getFrameSize
().
height
height
:
cc
.
view
.
getFrameSize
().
height
,
};
};
}
else
{
}
else
{
return
{
return
{
width
:
cc
.
game
.
canvas
.
clientWidth
,
width
:
cc
.
game
.
canvas
.
clientWidth
,
height
:
cc
.
game
.
canvas
.
clientHeight
height
:
cc
.
game
.
canvas
.
clientHeight
,
};
};
}
}
}
},
});
});
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