Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Sbox_FT_08
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
Sbox_FT_08
Commits
ce50afd9
Commit
ce50afd9
authored
Nov 24, 2020
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt screen size change
parent
a0f14d76
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
166 deletions
+23
-166
GameLogic.js
play/assets/tmpGame/script/GameLogic.js
+23
-15
Scene.js
play/assets/tmpGame/script/Scene.js
+0
-151
No files found.
play/assets/tmpGame/script/GameLogic.js
View file @
ce50afd9
...
@@ -31,7 +31,10 @@ export default class GameLogic {
...
@@ -31,7 +31,10 @@ export default class GameLogic {
this
.
g_cartoon
.
initLocalAudios
([
this
.
g_cartoon
.
initLocalAudios
([
"
test_audio
"
"
test_audio
"
])
])
this
.
initBg
()
this
.
initNodes
();
this
.
initNodes
();
this
.
resetPosition
();
this
.
initImageCards
();
this
.
initImageCards
();
this
.
initTitle
();
this
.
initTitle
();
// this.initQuestionPannel();
// this.initQuestionPannel();
...
@@ -63,23 +66,29 @@ export default class GameLogic {
...
@@ -63,23 +66,29 @@ export default class GameLogic {
this
.
g_cartoon
.
initCartoonElement
(
`card_
${
index
+
1
}
_bell_outline`
,
this
.
g_cartoon
.
getNodeByPath
(
`Canvas/card_
${
index
+
1
}
/bell/bell_outline`
));
this
.
g_cartoon
.
initCartoonElement
(
`card_
${
index
+
1
}
_bell_outline`
,
this
.
g_cartoon
.
getNodeByPath
(
`Canvas/card_
${
index
+
1
}
/bell/bell_outline`
));
this
.
g_cartoon
.
initCartoonElement
(
`card_
${
index
+
1
}
_image_container`
,
this
.
g_cartoon
.
getNodeByPath
(
`Canvas/card_
${
index
+
1
}
/container/image`
));
this
.
g_cartoon
.
initCartoonElement
(
`card_
${
index
+
1
}
_image_container`
,
this
.
g_cartoon
.
getNodeByPath
(
`Canvas/card_
${
index
+
1
}
/container/image`
));
}
}
// this.resetPosition()
}
initBg
()
{
const
bgNode
=
cc
.
find
(
'
Canvas/bgMain/bg
'
);
const
bgNodeSnow
=
cc
.
find
(
'
Canvas/bgMain/bg_snow
'
);
const
tree1
=
cc
.
find
(
'
Canvas/bgMain/tree_1
'
);
const
tree2
=
cc
.
find
(
'
Canvas/bgMain/tree_2/1
'
)
const
tree3
=
cc
.
find
(
'
Canvas/bgMain/tree_2/2
'
)
bgNode
.
scale
=
this
.
g_systemOption
.
mapScaleMax
;
bgNodeSnow
.
width
=
cc
.
winSize
.
width
tree1
.
height
=
cc
.
winSize
.
height
tree2
.
height
=
cc
.
winSize
.
height
tree3
.
height
=
cc
.
winSize
.
height
}
}
resetPosition
()
{
resetPosition
()
{
console
.
log
(
this
.
g_cartoon
.
getCartoonElement
(
"
question_title_pannel
"
))
const
bgNodeTitle
=
cc
.
find
(
'
Canvas/title
'
);
// this.g_cartoon.getCartoonElement("bottomPart_pannel").setLocation(this.g_systemOption.frameSize.width * this.g_systemOption.cocosScale, 4)
const
bgNodeSnow
=
cc
.
find
(
'
Canvas/bgMain/bg_snow
'
);
// this.g_cartoon.getCartoonElement("question_title_pannel").setLocation(this.g_systemOption.frameSize.width * this.g_systemOption.cocosScale / 2)
const
bgNodeShuicao
=
cc
.
find
(
'
Canvas/bgMain/shuicao
'
);
// this.g_cartoon.getCartoonElement(`selected_1`).setLocation(0)
bgNodeTitle
.
y
=
cc
.
winSize
.
height
/
2
-
bgNodeTitle
.
height
/
2
-
100
// this.g_cartoon.getCartoonElement(`selected_2`).setLocation(0)
bgNodeSnow
.
y
=
-
cc
.
winSize
.
height
/
2
+
bgNodeSnow
.
height
/
2
// this.g_cartoon.getCartoonElement(`selected_3`).setLocation(0)
bgNodeShuicao
.
y
=
-
cc
.
winSize
.
height
/
2
+
bgNodeShuicao
.
height
/
2
// this.g_cartoon.getCartoonElement(`selected_4`).setLocation(0)
// this.g_cartoon.getCartoonElement(`selected_5`).setLocation(cc.winSize.width - 150)
// this.g_cartoon.getCartoonElement(`selected_6`).setLocation(cc.winSize.width - 100)
// this.g_cartoon.getCartoonElement(`selected_7`).setLocation(cc.winSize.width - 80)
// this.g_cartoon.getCartoonElement(`selected_8`).setLocation(cc.winSize.width - 160)
// this.g_cartoon.getNodeByPath(`Canvas/center_image`).x = cc.winSize.width / 2 + 20
// this.g_cartoon.getNodeByPath(`Canvas/center_image`).y = cc.winSize.height / 2
}
}
initImageCards
()
{
initImageCards
()
{
...
@@ -110,7 +119,6 @@ export default class GameLogic {
...
@@ -110,7 +119,6 @@ export default class GameLogic {
})
})
}
}
bellOutline
.
node
.
setScale
(
0
);
bellOutline
.
node
.
setScale
(
0
);
this
.
g_cartoon
.
subscribeTouchEvent
(
`card_
${
index
+
1
}
_image_container`
,
()
=>
{
this
.
g_cartoon
.
subscribeTouchEvent
(
`card_
${
index
+
1
}
_image_container`
,
()
=>
{
...
...
play/assets/tmpGame/script/Scene.js
View file @
ce50afd9
...
@@ -148,8 +148,6 @@ cc.Class({
...
@@ -148,8 +148,6 @@ cc.Class({
loadEnd
()
{
loadEnd
()
{
this
.
initData
();
this
.
initData
();
this
.
initView
();
// this.initListener();
},
},
_cantouch
:
null
,
_cantouch
:
null
,
...
@@ -158,155 +156,6 @@ cc.Class({
...
@@ -158,155 +156,6 @@ cc.Class({
this
.
_cantouch
=
true
;
this
.
_cantouch
=
true
;
},
},
initView
()
{
this
.
initBg
();
// this.initPic();
// this.initBtn();
// this.initIcon();
},
initBg
()
{
const
bgNode
=
cc
.
find
(
'
Canvas/bgMain
'
);
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
)
=>
{
const
picNode2
=
sprNode
;
picNode2
.
scale
=
maxW
/
picNode2
.
width
;
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
);
});
},
initIcon
()
{
const
iconNode
=
this
.
getSprNode
(
'
icon
'
);
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
);
})
},
curPage
:
null
,
initBtn
()
{
this
.
curPage
=
0
;
const
bottomPart
=
cc
.
find
(
'
Canvas/bottomPart
'
);
bottomPart
.
zIndex
=
5
;
// 提高层级
bottomPart
.
x
=
bottomPart
.
parent
.
width
/
2
;
bottomPart
.
y
=
-
bottomPart
.
parent
.
height
/
2
;
const
leftBtnNode
=
bottomPart
.
getChildByName
(
'
btn_left
'
);
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode
.
on
(
'
click
'
,
()
=>
{
if
(
!
this
.
_cantouch
)
{
console
.
warn
(
"
_cantouch disabeld!
"
)
return
;
}
if
(
this
.
curPage
==
0
)
{
return
;
}
this
.
curPage
=
0
this
.
leftMove
();
cc
.
audioEngine
.
play
(
this
.
audioBtn
.
clip
,
false
,
0.8
)
})
const
rightBtnNode
=
bottomPart
.
getChildByName
(
'
btn_right
'
);
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode
.
on
(
'
click
'
,
()
=>
{
if
(
!
this
.
_cantouch
)
{
console
.
warn
(
"
_cantouch disabeld!
"
)
return
;
}
if
(
this
.
curPage
==
1
)
{
return
;
}
this
.
curPage
=
1
this
.
rightMove
();
cc
.
audioEngine
.
play
(
this
.
audioBtn
.
clip
,
false
,
0.5
)
})
},
leftMove
()
{
this
.
_cantouch
=
false
;
const
len
=
this
.
pic1
.
parent
.
width
;
cc
.
tween
(
this
.
pic1
)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
},
{
easing
:
'
cubicInOut
'
})
.
start
();
cc
.
tween
(
this
.
pic2
)
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
},
{
easing
:
'
cubicInOut
'
})
.
call
(()
=>
{
this
.
_cantouch
=
true
;
})
.
start
();
},
rightMove
()
{
this
.
_cantouch
=
false
;
const
len
=
this
.
pic1
.
parent
.
width
;
cc
.
tween
(
this
.
pic1
)
.
to
(
1
,
{
x
:
this
.
pic1
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
.
start
();
cc
.
tween
(
this
.
pic2
)
.
to
(
1
,
{
x
:
this
.
pic2
.
baseX
-
len
},
{
easing
:
'
cubicInOut
'
})
.
call
(()
=>
{
this
.
_cantouch
=
true
;
})
.
start
();
},
// 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