Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
LWD_3
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_3
Commits
e44191d5
Commit
e44191d5
authored
Dec 07, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改尺寸
parent
874a9214
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
667 additions
and
44 deletions
+667
-44
LWD_3.meta
assets/LWD_3.meta
+1
-15
LWD_3.fire
assets/LWD_3/scene/LWD_3.fire
+1
-1
LWD_3.js
assets/LWD_3/scene/LWD_3.js
+6
-6
view.js
assets/LWD_3/script/common/view.js
+64
-22
yarn.lock
yarn.lock
+595
-0
No files found.
assets/LWD_3.meta
View file @
e44191d5
{
"ver": "1.1.2",
"uuid": "551f3197-dce7-4bd2-a290-e784ab1d271a",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
{"ver":"1.1.2","uuid":"551f3197-dce7-4bd2-a290-e784ab1d271a","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
assets/LWD_3/scene/LWD_3.fire
View file @
e44191d5
...
...
@@ -559,7 +559,7 @@
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 4
4
,
"_alignFlags": 4,
"_left": 0,
"_right": 0,
"_top": 0,
...
...
assets/LWD_3/scene/LWD_3.js
View file @
e44191d5
...
...
@@ -43,12 +43,12 @@ var game = cc.Class({
//初始化游戏
this
.
initGame
();
//监听尺寸变化
if
(
window
.
addEventListener
)
{
window
.
addEventListener
(
'
resize
'
,
this
.
scaleEventCallBack
,
false
)
}
else
if
(
window
.
attachEvent
)
{
window
.
attachEvent
(
'
resize
'
,
this
.
scaleEventCallBack
,
false
)
}
//
//
监听尺寸变化
//
if (window.addEventListener) {
//
window.addEventListener('resize', this.scaleEventCallBack, false)
//
} else if (window.attachEvent) {
//
window.attachEvent('resize', this.scaleEventCallBack, false)
//
}
},
//屏幕缩放
...
...
assets/LWD_3/script/common/view.js
View file @
e44191d5
...
...
@@ -43,14 +43,16 @@ cc.Class({
onLoad
:
function
()
{
//开启适配
this
.
widgetList
=
[];
this
.
initSize
();
this
.
scheduleOnce
(
function
()
{
if
(
!
this
.
isCanvas
)
{
this
.
init
();
}
else
{
var
canvaSize
=
this
.
findCanvas
();
var
w
=
(
canvaSize
.
width
)
/
HEIGTH
;
var
h
=
(
canvaSize
.
height
)
/
WIDTH
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
//
var canvaSize = this.findCanvas();
//
var w = (canvaSize.width) / HEIGTH;
//
var h = (canvaSize.height) / WIDTH;
this
.
MaxSize
=
1
//
w / h > 1 ? w / h : h / w;
this
.
setUIMax
(
this
.
MaxSize
);
this
.
settopUI
(
this
.
MaxSize
);
...
...
@@ -60,7 +62,7 @@ cc.Class({
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
for
(
var
i
in
list
)
{
list
[
i
].
updateAlignment
();
//
list[i].updateAlignment();
}
}
},
0
);
...
...
@@ -71,23 +73,51 @@ cc.Class({
});
this
.
MaxSize
=
1
;
},
initSize
()
{
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let
screen_size
=
cc
.
view
.
getFrameSize
().
width
/
cc
.
view
.
getFrameSize
().
height
let
design_size
=
cc
.
Canvas
.
instance
.
designResolution
.
width
/
cc
.
Canvas
.
instance
.
designResolution
.
height
let
f
=
screen_size
>=
design_size
cc
.
Canvas
.
instance
.
fitHeight
=
f
cc
.
Canvas
.
instance
.
fitWidth
=
!
f
const
frameSize
=
cc
.
view
.
getFrameSize
();
this
.
_frameSize
=
frameSize
;
this
.
_designSize
=
cc
.
view
.
getDesignResolutionSize
();
let
sx
=
cc
.
winSize
.
width
/
frameSize
.
width
;
let
sy
=
cc
.
winSize
.
height
/
frameSize
.
height
;
this
.
_cocosScale
=
Math
.
min
(
sx
,
sy
);
sx
=
frameSize
.
width
/
this
.
_designSize
.
width
;
sy
=
frameSize
.
height
/
this
.
_designSize
.
height
;
this
.
_mapScaleMin
=
Math
.
min
(
sx
,
sy
)
*
this
.
_cocosScale
;
this
.
_mapScaleMax
=
Math
.
max
(
sx
,
sy
)
*
this
.
_cocosScale
;
this
.
canvas
=
cc
.
find
(
"
Canvas
"
);
},
init
:
function
()
{
var
canvaSize
=
this
.
findCanvas
();
var
diff
=
canvaSize
.
width
/
canvaSize
.
height
;
var
bili
=
WIDTH
/
HEIGTH
;
if
(
diff
>
bili
)
{
this
.
canvasView
.
fitWidth
=
false
;
this
.
canvasView
.
fitHeight
=
true
;
}
else
if
(
diff
<
bili
)
{
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitHeight
=
false
;
}
else
{
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitHeight
=
true
;
}
var
w
=
(
canvaSize
.
width
)
/
WIDTH
;
var
h
=
(
canvaSize
.
height
)
/
HEIGTH
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
//
var canvaSize = this.findCanvas();
//
var diff = canvaSize.width / canvaSize.height;
//
var bili = WIDTH / HEIGTH;
//
if (diff > bili) {
//
this.canvasView.fitWidth = false;
//
this.canvasView.fitHeight = true;
//
} else if (diff < bili) {
//
this.canvasView.fitWidth = true;
//
this.canvasView.fitHeight = false;
//
} else {
//
this.canvasView.fitWidth = true;
//
this.canvasView.fitHeight = true;
//
}
//
var w = (canvaSize.width) / WIDTH;
//
var h = (canvaSize.height) / HEIGTH;
this
.
MaxSize
=
1
//
w / h > 1 ? w / h : h / w;
LWD_3
.
data_mgr
.
MaxSize
=
this
.
MaxSize
;
this
.
setUIMax
(
this
.
MaxSize
);
...
...
@@ -97,7 +127,7 @@ cc.Class({
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
for
(
var
i
in
list
)
{
list
[
i
].
updateAlignment
();
//
list[i].updateAlignment();
}
},
...
...
@@ -126,6 +156,16 @@ cc.Class({
//背景适配
setBgScale
:
function
()
{
const
bg
=
cc
.
find
(
'
Canvas/bg
'
);
bg
.
scale
=
this
.
_mapScaleMax
;
const
grass
=
cc
.
find
(
'
Canvas/connent/bg_grass
'
);
grass
.
scaleX
=
this
.
canvas
.
width
/
grass
.
width
;
return
;
for
(
var
i
in
this
.
bgScaleMax
)
{
// 1. 先找到 SHOW_ALL 模式适配之后,本节点的实际宽高以及初始缩放值
let
scaleForShowAll
=
Math
.
min
(
...
...
@@ -145,6 +185,7 @@ cc.Class({
//适配节点位置
setUiPositon
:
function
()
{
return
;
for
(
var
i
in
this
.
nodeUIOffset
)
{
// 1. 先找到 SHOW_ALL 模式适配之后,本节点的实际宽高以及初始缩放值
let
srcScaleForShowAll
=
Math
.
min
(
...
...
@@ -161,6 +202,7 @@ cc.Class({
},
setUIMax
:
function
(
size
)
{
return
;
for
(
var
i
in
this
.
UIMax
)
{
if
(
this
.
UIMax
[
i
].
perScale
==
undefined
)
{
this
.
UIMax
[
i
].
perScale
=
this
.
UIMax
[
i
].
scaleX
;
...
...
yarn.lock
0 → 100644
View file @
e44191d5
This diff is collapsed.
Click to expand it.
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