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
6a5753de
Commit
6a5753de
authored
Nov 25, 2020
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev commit
parent
907b27de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
GameLogic.js
play/assets/tmpGame/script/GameLogic.js
+20
-19
No files found.
play/assets/tmpGame/script/GameLogic.js
View file @
6a5753de
...
...
@@ -95,7 +95,8 @@ export default class GameLogic {
initImageCards
()
{
let
newIndex
=
this
.
getRandomArray
(
10
)
this
.
m_currentQuestionArray
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]
console
.
log
(
"
正确序号:
"
,
newIndex
)
this
.
m_currentQuestionArray
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]
for
(
let
index
=
0
;
index
<
10
;
index
++
)
{
let
dataItem
=
this
.
g_formData
.
dataArray
[
newIndex
[
index
]];
let
card
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
+
1
}
`
)
...
...
@@ -106,7 +107,6 @@ export default class GameLogic {
imageContainer
.
correctIndex
=
newIndex
[
index
];
let
bellOutline
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
+
1
}
_bell_outline`
)
let
bellText
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
+
1
}
_bell_text`
)
bellText
.
node
.
getComponent
(
cc
.
Label
).
font
=
this
.
g_cartoon
.
getFontFamily
(
"
Comic Sans MS
"
)
bellText
.
node
.
getComponent
(
cc
.
Label
).
fontSize
=
20
...
...
@@ -137,9 +137,8 @@ export default class GameLogic {
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
i
+
1
}
_selected`
).
node
.
opacity
=
255
;
}
}
console
.
log
(
this
.
m_currentQuestion
,
imageContainer
.
correctIndex
)
if
(
this
.
m_currentQuestion
==
imageContainer
.
correctIndex
)
{
this
.
switchCard
(
imageContainer
.
correctIndex
,
imageContainer
.
cardIndex
)
this
.
switchCard
(
this
.
m_currentQuestion
,
imageContainer
.
cardIndex
)
this
.
loadQuestion
()
}
})
...
...
@@ -173,23 +172,28 @@ export default class GameLogic {
}
switchCard
(
fromIndex
,
toIndex
)
{
fromIndex
=
this
.
getCurrentIndex
(
fromIndex
+
1
)
toIndex
=
this
.
getCurrentIndex
(
toIndex
+
1
)
let
card_1
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
fromIndex
+
1
}
`
)
let
i1
=
this
.
m_currentQuestionArray
[
fromIndex
]
+
1
;
let
i2
=
this
.
m_currentQuestionArray
[
toIndex
]
let
card_1
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
i1
}
`
)
let
card_2
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
toIndex
+
1
}
`
)
console
.
log
(
"
交换
"
,
`card_
${
i1
}
`
,
`card_
${
toIndex
+
1
}
`
)
let
x
=
card_1
.
node
.
x
let
y
=
card_1
.
node
.
y
card_1
.
node
.
x
=
card_2
.
node
.
x
card_1
.
node
.
y
=
card_2
.
node
.
y
card_2
.
node
.
x
=
x
;
card_2
.
node
.
y
=
y
;
toIndex
=
this
.
getCurrentIndex
(
toIndex
)
let
bellText1
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
i1
}
_bell_text`
)
let
bellText2
=
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
toIndex
+
1
}
_bell_text`
)
bellText1
.
node
.
getComponent
(
cc
.
Label
).
string
=
""
+
(
toIndex
+
1
)
bellText2
.
node
.
getComponent
(
cc
.
Label
).
string
=
""
+
(
fromIndex
+
1
)
console
.
log
(
"
A
"
,
fromIndex
,
toIndex
)
let
temp
=
this
.
m_currentQuestionArray
[
fromIndex
]
this
.
m_currentQuestionArray
[
fromIndex
]
=
this
.
m_currentQuestionArray
[
toIndex
]
this
.
m_currentQuestionArray
[
toIndex
]
=
temp
;
console
.
log
(
"
B
"
,
this
.
m_currentQuestionArray
)
}
getCurrentIndex
(
index
)
{
...
...
@@ -286,18 +290,15 @@ export default class GameLogic {
}
loadQuestion
()
{
let
index
=
this
.
m_currentQuestionArray
[
this
.
m_currentQuestion
]
console
.
log
(
"
loadQuestion
"
,
index
,
this
.
m_currentQuestion
)
if
(
this
.
m_currentQuestion
!=
-
1
)
{
index
=
this
.
m_currentQuestionArray
[
this
.
m_currentQuestion
];
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
}
_normal`
).
node
.
opacity
=
255
;
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
}
_selected`
).
node
.
opacity
=
0
;
let
index
=
null
;
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
i
+
1
}
_normal`
).
node
.
opacity
=
255
;
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
i
+
1
}
_selected`
).
node
.
opacity
=
0
;
}
this
.
m_currentQuestion
++
;
index
=
this
.
m_currentQuestionArray
[
this
.
m_currentQuestion
]
console
.
log
(
"
loadQuestion
"
,
index
,
this
.
m_currentQuestion
)
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
}
_normal`
).
node
.
opacity
=
0
;
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
}
_selected`
).
node
.
opacity
=
255
;
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
+
1
}
_normal`
).
node
.
opacity
=
0
;
this
.
g_cartoon
.
getCartoonElement
(
`card_
${
index
+
1
}
_selected`
).
node
.
opacity
=
255
;
}
initQuestionPannel
()
{
...
...
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