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
34df0cb5
Commit
34df0cb5
authored
Apr 24, 2020
by
huangwenjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
977c6ace
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
PlayScene.ts
src/scenes/playScene/PlayScene.ts
+15
-1
No files found.
src/scenes/playScene/PlayScene.ts
View file @
34df0cb5
...
...
@@ -90,6 +90,7 @@ export class PlayScene extends Scene {
unlockGradeTxt
:
TextField
initUI
()
{
this
.
y
=
-
(
1624
-
layers
.
stageHeight
)
/
2
;
...
...
@@ -198,6 +199,19 @@ export class PlayScene extends Scene {
}
resetGame
()
{
for
(
let
x
=
0
;
x
<
4
;
x
++
)
{
for
(
let
y
=
0
;
y
<
4
;
y
++
)
{
this
.
board
[
x
][
y
]
=
0
}
}
this
.
generateOneElement
()
this
.
generateOneElement
()
this
.
renderBoard
()
this
.
score
=
0
}
createAniPool
=
[]
createArr
=
[
4
,
8
,
16
,
32
,
64
,
128
,
256
,
512
,
1024
,
2048
]
loadSvgas
()
{
...
...
@@ -919,7 +933,7 @@ export class PlayScene extends Scene {
// 随机生成基础元素
generateOneElement
()
{
// 随机生成一个数字 2or4
let
randNumber
=
Math
.
random
()
<
0.
9
?
2
:
4
let
randNumber
=
Math
.
random
()
<
0.
5
?
2
:
2048
// 随机生成位置
let
randNumberX
=
Math
.
floor
(
Math
.
random
()
*
4
)
let
randNumberY
=
Math
.
floor
(
Math
.
random
()
*
4
)
...
...
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