Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dfzx_ac2
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
dfzx_ac2
Commits
c3ec72f8
Commit
c3ec72f8
authored
Mar 23, 2021
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
ac11f82d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
141 deletions
+142
-141
Scene.js
play/assets/tmpGame/script/Scene.js
+142
-141
No files found.
play/assets/tmpGame/script/Scene.js
View file @
c3ec72f8
...
@@ -83,7 +83,8 @@ cc.Class({
...
@@ -83,7 +83,8 @@ cc.Class({
getData
((
data
)
=>
{
getData
((
data
)
=>
{
console
.
log
(
'
data:
'
,
data
);
console
.
log
(
'
data:
'
,
data
);
this
.
data
=
data
||
this
.
getDefaultData
();
this
.
data
=
data
||
this
.
getDefaultData
();
this
.
data
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
data
))
this
.
data
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
data
));
this
.
preloadItem
()
// this.preloadItem(_=>{
// this.preloadItem(_=>{
// this.gameLogic = new GameLogic(this.data, {
// this.gameLogic = new GameLogic(this.data, {
// designSize: this._designSize,
// designSize: this._designSize,
...
@@ -169,7 +170,7 @@ cc.Class({
...
@@ -169,7 +170,7 @@ cc.Class({
loadEnd
()
{
loadEnd
()
{
this
.
initData
();
this
.
initData
();
this
.
initAudio
();
this
.
initAudio
();
this
.
initView
();
//
this.initView();
// this.initListener();
// this.initListener();
},
},
...
@@ -192,145 +193,145 @@ cc.Class({
...
@@ -192,145 +193,145 @@ cc.Class({
},
},
initView
()
{
// initView() {
// this.initBg();
// // this.initBg();
// this.initPic();
// // this.initPic();
// this.initBtn();
// // this.initBtn();
// this.initIcon();
// // this.initIcon();
},
// },
initBg
()
{
const
bgNode
=
cc
.
find
(
'
Canvas/bg
'
);
bgNode
.
scale
=
this
.
_mapScaleMax
;
},
pic1
:
null
,
pic2
:
null
,
initPic
()
{
const
canvas
=
cc
.
find
(
'
Canvas
'
);
const
maxW
=
canvas
.
width
*
0.7
;
this
.
getSprNodeByUrl
(
this
.
data
.
pic_url
,
(
sprNode
)
=>
{
const
picNode1
=
sprNode
;
picNode1
.
scale
=
maxW
/
picNode1
.
width
;
picNode1
.
baseX
=
picNode1
.
x
;
canvas
.
addChild
(
picNode1
);
this
.
pic1
=
picNode1
;
const
labelNode
=
new
cc
.
Node
();
labelNode
.
color
=
cc
.
Color
.
YELLOW
;
const
label
=
labelNode
.
addComponent
(
cc
.
Label
);
label
.
string
=
this
.
data
.
text
;
label
.
fontSize
=
60
;
label
.
lineHeight
=
60
;
label
.
font
=
cc
.
find
(
'
Canvas/res/font/BRLNSDB
'
).
getComponent
(
'
cc.Label
'
).
font
;
picNode1
.
addChild
(
labelNode
);
});
this
.
getSprNodeByUrl
(
this
.
data
.
pic_url_2
,
(
sprNode
)
=>
{
// initBg() {
const
picNode2
=
sprNode
;
// const bgNode = cc.find('Canvas/bg');
picNode2
.
scale
=
maxW
/
picNode2
.
width
;
// bgNode.scale = this._mapScaleMax;
canvas
.
addChild
(
picNode2
);
// },
picNode2
.
x
=
canvas
.
width
;
picNode2
.
baseX
=
picNode2
.
x
;
this
.
pic2
=
picNode2
;
const
labelNode
=
new
cc
.
Node
();
const
label
=
labelNode
.
addComponent
(
cc
.
RichText
);
const
size
=
60
label
.
font
=
cc
.
find
(
'
Canvas/res/font/BRLNSDB
'
).
getComponent
(
cc
.
Label
).
font
;
label
.
string
=
`<outline color=#751e00 width=4><size=
${
size
}
><color=#ffffff>
${
this
.
data
.
text
}
</color></size></outline>`
label
.
lineHeight
=
size
;
picNode2
.
addChild
(
labelNode
);
});
},
// pic1: null,
// pic2: null,
// initPic() {
// const canvas = cc.find('Canvas');
// const maxW = canvas.width * 0.7;
// this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
// const picNode1 = sprNode;
// picNode1.scale = maxW / picNode1.width;
// picNode1.baseX = picNode1.x;
// canvas.addChild(picNode1);
// this.pic1 = picNode1;
// const labelNode = new cc.Node();
// labelNode.color = cc.Color.YELLOW;
// const label = labelNode.addComponent(cc.Label);
// label.string = this.data.text;
// label.fontSize = 60;
// label.lineHeight = 60;
// label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
// picNode1.addChild(labelNode);
// });
initIcon
()
{
// this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const
iconNode
=
this
.
getSprNode
(
'
icon
'
);
// const picNode2 = sprNode;
iconNode
.
zIndex
=
5
;
// picNode2.scale = maxW / picNode2.width;
iconNode
.
anchorX
=
1
;
// canvas.addChild(picNode2);
iconNode
.
anchorY
=
1
;
// picNode2.x = canvas.width;
iconNode
.
parent
=
cc
.
find
(
'
Canvas
'
);
// picNode2.baseX = picNode2.x;
iconNode
.
x
=
iconNode
.
parent
.
width
/
2
-
10
;
// this.pic2 = picNode2;
iconNode
.
y
=
iconNode
.
parent
.
height
/
2
-
10
;
// const labelNode = new cc.Node();
iconNode
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
// const label = labelNode.addComponent(cc.RichText);
this
.
playAudioByUrl
(
this
.
data
.
audio_url
);
// const size = 60
})
// label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
},
// label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
// label.lineHeight = size;
// picNode2.addChild(labelNode);
// });
curPage
:
null
,
// },
initBtn
()
{
this
.
curPage
=
0
;
// initIcon() {
const
bottomPart
=
cc
.
find
(
'
Canvas/bottomPart
'
);
// const iconNode = this.getSprNode('icon');
bottomPart
.
zIndex
=
5
;
// 提高层级
// iconNode.zIndex = 5;
// iconNode.anchorX = 1;
// iconNode.anchorY = 1;
// iconNode.parent = cc.find('Canvas');
// iconNode.x = iconNode.parent.width / 2 - 10;
// iconNode.y = iconNode.parent.height / 2 - 10;
// iconNode.on(cc.Node.EventType.TOUCH_START, () => {
// this.playAudioByUrl(this.data.audio_url);
// })
// },
bottomPart
.
x
=
bottomPart
.
parent
.
width
/
2
;
// curPage: null,
bottomPart
.
y
=
-
bottomPart
.
parent
.
height
/
2
;
// initBtn() {
const
leftBtnNode
=
bottomPart
.
getChildByName
(
'
btn_left
'
);
// this.curPage = 0;
//节点中添加了button组件 则可以添加click事件监听
// const bottomPart = cc.find('Canvas/bottomPart');
leftBtnNode
.
on
(
'
click
'
,
()
=>
{
// bottomPart.zIndex = 5; // 提高层级
if
(
!
this
.
_cantouch
)
{
return
;
}
if
(
this
.
curPage
==
0
)
{
return
;
}
this
.
curPage
=
0
this
.
leftMove
();
cc
.
audioEngine
.
play
(
this
.
audioBtn
.
clip
,
false
,
0.8
)
// bottomPart.x = bottomPart.parent.width / 2;
})
// bottomPart.y = -bottomPart.parent.height / 2;
const
rightBtnNode
=
bottomPart
.
getChildByName
(
'
btn_right
'
);
// const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
// //节点中添加了button组件 则可以添加click事件监听
rightBtnNode
.
on
(
'
click
'
,
()
=>
{
// leftBtnNode.on('click', () => {
if
(
!
this
.
_cantouch
)
{
// if (!this._cantouch) {
return
;
// return;
}
// }
if
(
this
.
curPage
==
1
)
{
// if (this.curPage == 0) {
return
;
// return;
}
// }
// this.curPage = 0
// this.leftMove();
this
.
curPage
=
1
// cc.audioEngine.play(this.audioBtn.clip, false, 0.8)
this
.
rightMove
();
// })
cc
.
audioEngine
.
play
(
this
.
audioBtn
.
clip
,
false
,
0.5
)
// const rightBtnNode = bottomPart.getChildByName('btn_right');
})
// //节点中添加了button组件 则可以添加click事件监听
},
// rightBtnNode.on('click', () => {
// if (!this._cantouch) {
// return;
// }
// if (this.curPage == 1) {
// return;
// }
leftMove
()
{
// this.curPage = 1
this
.
_cantouch
=
false
;
// this.rightMove();
const
len
=
this
.
pic1
.
parent
.
width
;
cc
.
tween
(
this
.
pic1
)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
},
{
easing
:
'
cubicInOut
'
})
.
start
();
cc
.
tween
(
this
.
pic2
)
// cc.audioEngine.play(this.audioBtn.clip, false, 0.5)
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
},
{
easing
:
'
cubicInOut
'
})
// })
.
call
(()
=>
{
// },
this
.
_cantouch
=
true
;
})
.
start
();
},
rightMove
()
{
// leftMove() {
this
.
_cantouch
=
false
;
// this._cantouch = false;
const
len
=
this
.
pic1
.
parent
.
width
;
// const len = this.pic1.parent.width;
cc
.
tween
(
this
.
pic1
)
// cc.tween(this.pic1)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
// .to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.
start
();
// .start();
// cc.tween(this.pic2)
// .to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
// .call(() => {
// this._cantouch = true;
// })
// .start();
// },
cc
.
tween
(
this
.
pic2
)
// rightMove() {
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
// this._cantouch = false;
.
call
(()
=>
{
// const len = this.pic1.parent.width;
this
.
_cantouch
=
true
;
// cc.tween(this.pic1)
})
// .to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.
start
();
// .start();
},
// cc.tween(this.pic2)
// .to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
// .call(() => {
// this._cantouch = true;
// })
// .start();
// },
// update (dt) {},
// update (dt) {},
...
...
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