Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cc_mz_003
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
cc_mz_003
Commits
8e694ef6
Commit
8e694ef6
authored
Jan 08, 2021
by
Li MingZhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 底部item 宽度适配
parent
bd312ab7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
119 deletions
+98
-119
.DS_Store
play/assets/.DS_Store
+0
-0
.DS_Store
play/assets/mz_003/.DS_Store
+0
-0
bgBottom.js
play/assets/mz_003/prefab/bgBottom.js
+61
-48
scene.fire
play/assets/mz_003/scene/scene.fire
+0
-71
02封面.png
play/assets/mz_003/texture/02封面.png
+0
-0
02封面.png.meta
play/assets/mz_003/texture/02封面.png.meta
+37
-0
No files found.
play/assets/.DS_Store
View file @
8e694ef6
No preview for this file type
play/assets/mz_003/.DS_Store
View file @
8e694ef6
No preview for this file type
play/assets/mz_003/prefab/bgBottom.js
View file @
8e694ef6
...
...
@@ -22,6 +22,7 @@ cc.Class({
_maxPage
:
null
,
_lineMaxCount
:
null
,
_disW
:
null
,
_maxW
:
null
,
onLoad
()
{
this
.
_canTouch
=
true
;
this
.
_isTop
=
false
;
...
...
@@ -35,8 +36,8 @@ cc.Class({
this
.
_maxPage
=
0
;
this
.
_disW
=
5
;
const
maxW
=
1280
-
90
;
this
.
_lineMaxCount
=
Math
.
floor
(
maxW
/
(
this
.
_disW
+
this
.
_itemLen
));
this
.
_
maxW
=
1280
-
90
;
this
.
_lineMaxCount
=
Math
.
floor
(
this
.
_
maxW
/
(
this
.
_disW
+
this
.
_itemLen
));
},
...
...
@@ -112,7 +113,7 @@ cc.Class({
return
;
}
if
(
this
.
_pageIndex
>=
this
.
_maxPage
)
{
if
(
this
.
_pageIndex
>=
this
.
_maxPage
-
1
)
{
return
;
}
this
.
_pageIndex
++
;
...
...
@@ -142,7 +143,7 @@ cc.Class({
this
.
_pageUpBtn
.
opacity
=
255
;
}
if
(
this
.
_pageIndex
==
this
.
_maxPage
)
{
if
(
this
.
_pageIndex
==
this
.
_maxPage
-
1
)
{
this
.
_pageDownBtn
.
opacity
=
100
;
}
else
{
this
.
_pageDownBtn
.
opacity
=
255
;
...
...
@@ -185,12 +186,35 @@ cc.Class({
return
;
}
this
.
_dataArr
=
dataArr
;
this
.
_maxPage
=
Math
.
ceil
(
dataArr
.
length
/
this
.
_lineMaxCount
)
-
1
;
// this._maxPage = Math.ceil(dataArr.length / this._lineMaxCount) - 1;
this
.
_initPageArr
();
this
.
_pageIndex
=
0
;
this
.
_refreshPage
();
},
_pageArr
:
null
,
_initPageArr
()
{
let
tmpArr
=
[];
this
.
_pageArr
=
[
tmpArr
];
let
curLen
=
this
.
_disW
;
for
(
let
i
=
0
;
i
<
this
.
_dataArr
.
length
;
i
++
)
{
const
item
=
this
.
_addOneItem
(
this
.
_dataArr
[
i
]);
curLen
+=
item
.
width
+
this
.
_disW
;
if
(
curLen
>
this
.
_maxW
)
{
tmpArr
=
[
item
];
this
.
_pageArr
.
push
(
tmpArr
);
}
else
{
tmpArr
.
push
(
item
);
}
}
this
.
_maxPage
=
this
.
_pageArr
.
length
;
console
.
log
(
'
this._maxPage:
'
,
this
.
_maxPage
);
},
_itemLen
:
null
,
_addOneItem
(
data
)
{
...
...
@@ -198,7 +222,6 @@ cc.Class({
const
item
=
new
cc
.
Node
();
item
.
width
=
this
.
_itemLen
;
item
.
height
=
this
.
_itemLen
;
item
.
data
=
data
;
// const rect = item.addComponent(cc.Graphics);
// rect.fillColor = cc.Color.BLACK.setA(100);
// rect.fillRect(-this._itemLen / 2, -this._itemLen / 2, this._itemLen, this._itemLen);
...
...
@@ -207,12 +230,8 @@ cc.Class({
this
.
_addItemPic
(
item
,
data
.
pic_url
);
this
.
_addItemLabel
(
item
,
data
.
text
);
this
.
_addItemAudio
(
item
,
data
.
audio_url
);
this
.
_addItemListener
(
item
);
if
(
data
.
isClicked
)
{
item
.
opacity
=
100
;
}
item
.
data
=
data
;
return
item
;
},
...
...
@@ -260,6 +279,10 @@ cc.Class({
}
label
.
font
=
this
.
_labelFont
;
label
.
_forceUpdateRenderData
(
true
)
if
(
labelNode
.
width
>
this
.
_itemLen
)
{
item
.
width
=
labelNode
.
width
;
}
},
...
...
@@ -270,43 +293,18 @@ cc.Class({
cc
.
assetManager
.
loadRemote
(
url
,
(
err
,
audioClip
)
=>
{
item
.
audioClip
=
audioClip
;
this
.
_addItemListener
(
item
);
});
},
_addItemListener
(
item
)
{
// item.addComponent(cc.Button);
// item.on('click', () => {
//
// this.node.emit('item_click', item);
//
// // if (item.audioClip) {
// // cc.audioEngine.stopAll();
// // cc.audioEngine.play(item.audioClip, false, 0.5);
// // }
// });
const
touchStart
=
(
e
)
=>
{
console
.
log
(
'
touch start
'
);
this
.
node
.
emit
(
'
item_touch_start
'
,
item
);
if
(
item
.
hasEventListener
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
))
{
item
.
off
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
,
mouseDown
)
}
item
.
addComponent
(
cc
.
Button
);
item
.
on
(
'
click
'
,
()
=>
{
if
(
item
.
audioClip
)
{
cc
.
audioEngine
.
stopAll
();
cc
.
audioEngine
.
play
(
item
.
audioClip
,
false
,
0.5
);
}
const
mouseDown
=
(
e
)
=>
{
console
.
log
(
'
mouse down
'
);
this
.
node
.
emit
(
'
item_touch_start
'
,
item
);
if
(
item
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_START
))
{
item
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
,
touchStart
)
}
}
item
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
touchStart
);
item
.
on
(
cc
.
Node
.
EventType
.
MOUSE_DOWN
,
mouseDown
);
});
},
_refreshPage
()
{
...
...
@@ -317,20 +315,35 @@ cc.Class({
const
disW
=
this
.
_disW
;
const
startIndex
=
this
.
_pageIndex
*
this
.
_lineMaxCount
;
const
showArr
=
dataArr
.
slice
(
startIndex
,
startIndex
+
this
.
_lineMaxCount
);
// const showArr = dataArr.slice(startIndex, startIndex + this._lineMaxCount);
const
showArr
=
this
.
_pageArr
[
this
.
_pageIndex
];
let
baseX
=
this
.
_getCurPageBaseX
();
const
baseX
=
-
(
disW
+
this
.
_itemLen
)
*
(
showArr
.
length
-
1
)
/
2
;
// const baseX = -(disW + this._itemLen) * (showArr.length - 1) / 2;
const
baseY
=
-
25
;
showArr
.
forEach
((
data
,
i
)
=>
{
const
item
=
this
.
_addOneItem
(
data
);
showArr
.
forEach
((
el
,
i
)
=>
{
const
item
=
this
.
_addOneItem
(
el
.
data
);
this
.
_itemLayer
.
addChild
(
item
);
item
.
x
=
baseX
+
(
disW
+
this
.
_itemLen
)
*
i
;
item
.
x
=
baseX
+
(
disW
+
item
.
width
)
/
2
item
.
y
=
baseY
;
baseX
=
item
.
x
+
(
disW
+
item
.
width
)
/
2
;
});
this
.
_setPageBtnState
();
},
_getCurPageBaseX
()
{
const
arr
=
this
.
_pageArr
[
this
.
_pageIndex
];
console
.
log
(
'
arr:
'
,
arr
);
let
curLen
=
this
.
_disW
;
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
curLen
+=
(
arr
[
i
].
width
+
this
.
_disW
)
}
return
-
curLen
/
2
;
},
// update (dt) {},
});
play/assets/mz_003/scene/scene.fire
View file @
8e694ef6
...
...
@@ -97,9 +97,6 @@
},
{
"__id__": 56
},
{
"__id__": 57
}
],
"_prefab": null,
...
...
@@ -2302,73 +2299,5 @@
"baseWidth": 1280,
"baseHeight": 720,
"_id": "28v7Et3UdB3JZRlTOtLFi9"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "2epwvLwn5JJZdxF95DIVhW"
}
]
\ No newline at end of file
play/assets/mz_003/texture/02封面.png
0 → 100644
View file @
8e694ef6
This diff is collapsed.
Click to expand it.
play/assets/mz_003/texture/02封面.png.meta
0 → 100644
View file @
8e694ef6
{
"ver": "2.3.5",
"uuid": "a34b7897-1edf-4bb8-84f2-c97c4cb122ea",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"platformSettings": {},
"subMetas": {
"02封面": {
"ver": "1.0.4",
"uuid": "650e77e4-49a4-4cd9-8da0-122684dbbec1",
"rawTextureUuid": "a34b7897-1edf-4bb8-84f2-c97c4cb122ea",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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