Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game2048
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
熊东起
game2048
Commits
1f50f558
Commit
1f50f558
authored
Apr 24, 2020
by
wjf
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab2.dui88.com:MrKwon/game2048
parents
4043dbc1
f2dadebc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
17 deletions
+63
-17
PlayScene.ts
src/scenes/playScene/PlayScene.ts
+63
-17
No files found.
src/scenes/playScene/PlayScene.ts
View file @
1f50f558
...
...
@@ -1041,10 +1041,12 @@ export class PlayScene extends Scene {
currMoveType
combineCount
:
number
=
0
addScore
:
number
=
0
moveToLeft
(
type
)
{
let
arr
=
[],
tag
=
false
this
.
currMoveType
=
"left"
this
.
combineCount
=
0
this
.
addScore
=
0
for
(
let
x
=
0
;
x
<
4
;
x
++
)
{
arr
[
x
]
=
new
Array
()
arr
[
x
]
=
this
.
board
[
x
]
...
...
@@ -1054,6 +1056,20 @@ export class PlayScene extends Scene {
}
}
this
.
score
+=
this
.
addScore
if
(
this
.
addScore
>
0
)
{
this
.
scoreTips
=
this
.
drawTxt
(
"+"
+
this
.
addScore
,
250
,
340
,
"#ffffff"
,
34
)
this
.
scoreTips
.
alpha
=
0
this
.
addChild
(
this
.
scoreTips
)
Tween
.
get
(
this
.
scoreTips
)
.
to
({
y
:
300
,
alpha
:
1
},
200
)
.
wait
(
200
)
.
to
({
y
:
250
,
alpha
:
0
},
100
)
.
call
(()
=>
{
this
.
removeChild
(
this
.
scoreTips
)
})
}
if
(
this
.
combineCount
>
0
)
{
if
(
this
.
combineCount
==
1
)
{
checkMusic
(
"createEle"
,
this
.
isPlayMusic
)
...
...
@@ -1072,6 +1088,7 @@ export class PlayScene extends Scene {
let
arr
=
[],
tag
=
false
this
.
currMoveType
=
"top"
this
.
combineCount
=
0
this
.
addScore
=
0
for
(
let
y
=
0
;
y
<
4
;
y
++
)
{
arr
[
y
]
=
new
Array
()
for
(
let
x
=
0
;
x
<
4
;
x
++
)
{
...
...
@@ -1084,6 +1101,20 @@ export class PlayScene extends Scene {
}
}
this
.
score
+=
this
.
addScore
if
(
this
.
addScore
>
0
)
{
this
.
scoreTips
=
this
.
drawTxt
(
"+"
+
this
.
addScore
,
250
,
340
,
"#ffffff"
,
34
)
this
.
scoreTips
.
alpha
=
0
this
.
addChild
(
this
.
scoreTips
)
Tween
.
get
(
this
.
scoreTips
)
.
to
({
y
:
300
,
alpha
:
1
},
200
)
.
wait
(
200
)
.
to
({
y
:
250
,
alpha
:
0
},
100
)
.
call
(()
=>
{
this
.
removeChild
(
this
.
scoreTips
)
})
}
if
(
this
.
combineCount
>
0
)
{
if
(
this
.
combineCount
==
1
)
{
checkMusic
(
"createEle"
,
this
.
isPlayMusic
)
...
...
@@ -1109,6 +1140,7 @@ export class PlayScene extends Scene {
let
arr
=
[],
tag
=
false
this
.
currMoveType
=
"right"
this
.
combineCount
=
0
this
.
addScore
=
0
for
(
let
x
=
0
;
x
<
4
;
x
++
)
{
arr
[
x
]
=
new
Array
()
// 数组反向传入处理函数
...
...
@@ -1120,6 +1152,20 @@ export class PlayScene extends Scene {
if
(
type
)
this
.
updateArr
(
arr
[
x
],
x
)
}
this
.
score
+=
this
.
addScore
if
(
this
.
addScore
>
0
)
{
this
.
scoreTips
=
this
.
drawTxt
(
"+"
+
this
.
addScore
,
250
,
340
,
"#ffffff"
,
34
)
this
.
scoreTips
.
alpha
=
0
this
.
addChild
(
this
.
scoreTips
)
Tween
.
get
(
this
.
scoreTips
)
.
to
({
y
:
300
,
alpha
:
1
},
200
)
.
wait
(
200
)
.
to
({
y
:
250
,
alpha
:
0
},
100
)
.
call
(()
=>
{
this
.
removeChild
(
this
.
scoreTips
)
})
}
if
(
this
.
combineCount
>
0
)
{
if
(
this
.
combineCount
==
1
)
{
checkMusic
(
"createEle"
,
this
.
isPlayMusic
)
...
...
@@ -1144,6 +1190,7 @@ export class PlayScene extends Scene {
let
arr
=
[],
tag
=
false
this
.
currMoveType
=
"bottom"
this
.
combineCount
=
0
this
.
addScore
=
0
for
(
let
y
=
0
;
y
<
4
;
y
++
)
{
arr
[
y
]
=
new
Array
()
for
(
let
x
=
0
;
x
<
4
;
x
++
)
{
...
...
@@ -1153,6 +1200,20 @@ export class PlayScene extends Scene {
if
(
type
)
this
.
updateArr
(
arr
[
y
],
y
)
}
this
.
score
+=
this
.
addScore
if
(
this
.
addScore
>
0
)
{
this
.
scoreTips
=
this
.
drawTxt
(
"+"
+
this
.
addScore
,
250
,
340
,
"#ffffff"
,
34
)
this
.
scoreTips
.
alpha
=
0
this
.
addChild
(
this
.
scoreTips
)
Tween
.
get
(
this
.
scoreTips
)
.
to
({
y
:
300
,
alpha
:
1
},
200
)
.
wait
(
200
)
.
to
({
y
:
250
,
alpha
:
0
},
100
)
.
call
(()
=>
{
this
.
removeChild
(
this
.
scoreTips
)
})
}
if
(
this
.
combineCount
>
0
)
{
if
(
this
.
combineCount
==
1
)
{
...
...
@@ -1193,7 +1254,6 @@ export class PlayScene extends Scene {
}
}
// 判断相加/合并
let
addScore
=
0
for
(
let
i
=
1
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
===
0
)
break
if
(
arr
[
i
]
===
arr
[
i
-
1
]
&&
arr
[
i
-
1
]
<
2048
)
{
...
...
@@ -1253,23 +1313,9 @@ export class PlayScene extends Scene {
}
})
addScore
+=
arr
[
i
-
1
]
this
.
score
+=
arr
[
i
-
1
]
}
if
(
addScore
>
0
)
{
this
.
scoreTips
=
this
.
drawTxt
(
"+"
+
addScore
,
250
,
340
,
"#ffffff"
,
34
)
this
.
scoreTips
.
alpha
=
0
this
.
addChild
(
this
.
scoreTips
)
Tween
.
get
(
this
.
scoreTips
)
.
to
({
y
:
300
,
alpha
:
1
},
200
)
.
wait
(
200
)
.
to
({
y
:
250
,
alpha
:
0
},
100
)
.
call
(()
=>
{
this
.
removeChild
(
this
.
scoreTips
)
})
this
.
addScore
+=
arr
[
i
-
1
]
// this.score += arr[i - 1]
}
}
}
...
...
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