Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ireadabcMiddleLayer
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
ireadabcMiddleLayer
Commits
1720e51d
Commit
1720e51d
authored
Mar 08, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: storyBox 适配
parent
da5c2128
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
16 deletions
+55
-16
middleLayer.js
assets/ireadabcMiddleLayer/script/middleLayer.js
+55
-16
No files found.
assets/ireadabcMiddleLayer/script/middleLayer.js
View file @
1720e51d
...
...
@@ -618,28 +618,67 @@ cc.Class({
this
.
hideWaitingLetters
();
callback
&&
callback
();
if
(
this
.
bundleType
==
'
StoryBox
'
)
{
canvas
.
getComponent
(
cc
.
Widget
).
updateAlignment
();
middleLayer
.
getComponent
(
cc
.
Widget
).
updateAlignment
();
const
frameSize
=
cc
.
view
.
getFrameSize
();
console
.
log
(
`Canvas.size =
${
canvas
.
width
}
,
${
canvas
.
height
}
`
);
console
.
log
(
`frameSize.size =
${
frameSize
.
width
}
,
${
frameSize
.
height
}
`
);
console
.
log
(
`middleLayer.size =
${
middleLayer
.
width
}
,
${
middleLayer
.
height
}
`
);
const
scale
=
(
middleLayer
.
width
/
frameSize
.
width
);
console
.
log
(
'
scale =
'
+
scale
);
const
middleLayerWidget
=
middleLayer
.
getComponent
(
cc
.
Widget
);
middleLayerWidget
.
isAlignHorizontalCenter
=
true
;
// Boolean 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。
middleLayerWidget
.
isAlignVerticalCenter
=
true
;
// Boolean 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。
// middleLayer.removeComponent(cc.Widget);
middleLayer
.
width
=
frameSize
.
width
*
scale
;
middleLayer
.
height
=
frameSize
.
height
*
scale
;
this
.
node
.
removeComponent
(
cc
.
Widget
);
this
.
updateScale
();
}
});
});
});
},
updateScale
()
{
console
.
log
(
"
updateScale
"
);
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
scale
=
Math
.
max
(
designSize
.
width
/
canvasSize
.
width
,
designSize
.
height
/
canvasSize
.
height
);
const
scaleHeight
=
this
.
node
.
height
/
canvasSize
.
height
;
this
.
node
.
width
=
canvasSize
.
width
*
scaleHeight
;
this
.
node
.
scale
=
scale
/
scaleHeight
;
const
pos
=
this
.
node
.
parent
.
convertToNodeSpaceAR
(
canvas
.
convertToWorldSpaceAR
(
cc
.
v2
(
0
,
0
))
);
this
.
node
.
setPosition
(
pos
);
return
;
}
if
(
canvasComponent
.
fitHeight
&&
!
canvasComponent
.
fitWidth
)
{
console
.
log
(
"
fit height
"
);
const
scale
=
designSize
.
height
/
canvasSize
.
height
;
const
scaleHeight
=
this
.
node
.
height
/
canvasSize
.
height
;
this
.
node
.
width
=
canvasSize
.
width
*
scaleHeight
;
this
.
node
.
scale
=
scale
/
scaleHeight
;
this
.
node
.
x
=
(
this
.
node
.
width
*
this
.
node
.
scale
)
/
2
;
this
.
node
.
y
=
(
this
.
node
.
height
*
this
.
node
.
scale
)
/
2
;
return
;
}
if
(
!
canvasComponent
.
fitHeight
&&
canvasComponent
.
fitWidth
)
{
console
.
log
(
"
fit width
"
);
const
scale
=
designSize
.
width
/
canvasSize
.
width
;
const
scaleWidth
=
this
.
node
.
width
/
canvasSize
.
width
;
this
.
node
.
height
=
canvasSize
.
height
*
scaleWidth
;
this
.
node
.
scale
=
scale
/
scaleWidth
;
this
.
node
.
x
=
(
this
.
node
.
width
*
this
.
node
.
scale
)
/
2
;
this
.
node
.
y
=
(
this
.
node
.
height
*
this
.
node
.
scale
)
/
2
;
return
;
}
},
loadBundleByConf
(
conf
,
callback
)
{
if
(
cc
.
sys
.
isNative
&&
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
this
.
loadBundle
(
conf
.
ios
,
callback
);
...
...
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