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
276189de
Commit
276189de
authored
Apr 21, 2020
by
huangwenjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a5dfe921
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
22 deletions
+30
-22
Main.ts
src/Main.ts
+2
-2
StartScene.ts
src/scenes/StartScene.ts
+2
-2
PlayScene.ts
src/scenes/playScene/PlayScene.ts
+26
-18
No files found.
src/Main.ts
View file @
276189de
...
@@ -30,7 +30,7 @@ window.addEventListener("load", function () {
...
@@ -30,7 +30,7 @@ window.addEventListener("load", function () {
var
r
=
document
.
createElement
(
"script"
);
var
r
=
document
.
createElement
(
"script"
);
r
.
async
=
!
0
,
r
.
src
=
"//yun.tuia.cn/tuia/skyeye/skyeye.js"
,
r
.
crossOrigin
=
"anonymous"
,
r
.
onerror
=
r
.
async
=
!
0
,
r
.
src
=
"//yun.tuia.cn/tuia/skyeye/skyeye.js"
,
r
.
crossOrigin
=
"anonymous"
,
r
.
onerror
=
function
()
{
function
()
{
t
--
,
t
>
0
&&
setTimeout
(
e
,
1500
)
t
--
,
t
>
0
&&
setTimeout
(
e
,
1500
)
},
document
.
head
&&
document
.
head
.
appendChild
(
r
)
},
document
.
head
&&
document
.
head
.
appendChild
(
r
)
};
};
setTimeout
(
n
,
1500
);
setTimeout
(
n
,
1500
);
...
@@ -62,7 +62,7 @@ export class Main {
...
@@ -62,7 +62,7 @@ export class Main {
//隐藏加载中
//隐藏加载中
if
(
document
.
getElementById
(
"__loading__"
))
document
.
getElementById
(
"__loading__"
).
style
.
display
=
"none"
;
if
(
document
.
getElementById
(
"__loading__"
))
document
.
getElementById
(
"__loading__"
).
style
.
display
=
"none"
;
//打开开始场景
//打开开始场景
changeScene
(
StartScene
);
return
;
changeScene
(
PlayScene
);
return
;
//获取数据,,必成功
//获取数据,,必成功
showWaiting
();
showWaiting
();
sendTbNet
(
TbNetName
.
getAppData
,
{},
(
s
,
res
)
=>
{
sendTbNet
(
TbNetName
.
getAppData
,
{},
(
s
,
res
)
=>
{
...
...
src/scenes/StartScene.ts
View file @
276189de
import
{
PlayScene
}
from
'./playScene/PlayScene'
;
import
Sprite
from
"../../engine/2d/display/Sprite"
;
import
Sprite
from
"../../engine/2d/display/Sprite"
;
...
@@ -25,7 +26,6 @@ import { AdvancedBloomFilter } from "../../engine/2d/filter/advanced-bloom/Advan
...
@@ -25,7 +26,6 @@ import { AdvancedBloomFilter } from "../../engine/2d/filter/advanced-bloom/Advan
import
{
Scene
}
from
"../../module/views/Scene"
;
import
{
Scene
}
from
"../../module/views/Scene"
;
import
{
RES
}
from
"../../module/RES"
;
import
{
RES
}
from
"../../module/RES"
;
import
{
changeScene
}
from
"../../module/ctrls"
;
import
{
changeScene
}
from
"../../module/ctrls"
;
import
{
PlayScene
}
from
"./PlayScene"
;
import
{
layers
}
from
"../../module/views/layers"
;
import
{
layers
}
from
"../../module/views/layers"
;
import
{
NineSlicePlane
}
from
'../../engine/2d/mesh'
;
import
{
NineSlicePlane
}
from
'../../engine/2d/mesh'
;
import
{
Rope
}
from
'../../engine/2d/mesh/Rope'
;
import
{
Rope
}
from
'../../engine/2d/mesh/Rope'
;
...
...
src/scenes/playScene/PlayScene.ts
View file @
276189de
...
@@ -113,6 +113,21 @@ export class PlayScene extends Scene {
...
@@ -113,6 +113,21 @@ export class PlayScene extends Scene {
initEvents
()
{
initEvents
()
{
super
.
initEvents
()
super
.
initEvents
()
this
.
addEventListener
(
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown_this
,
this
)
this
.
addEventListener
(
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown_this
,
this
)
this
.
addEventListener
(
MouseEvent
.
CLICK
,
this
.
onClick_exchangeBtn
,
this
)
this
.
addEventListener
(
MouseEvent
.
CLICK
,
this
.
onClick_bombBtn
,
this
)
this
.
addEventListener
(
MouseEvent
.
CLICK
,
this
.
onClick_filterBtn
,
this
)
}
onClick_exchangeBtn
()
{
}
onClick_bombBtn
()
{
}
onClick_filterBtn
()
{
}
}
startX
startX
...
@@ -144,6 +159,7 @@ export class PlayScene extends Scene {
...
@@ -144,6 +159,7 @@ export class PlayScene extends Scene {
}
}
onUp_this
()
{
onUp_this
()
{
this
.
removeEventListener
(
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove_this
,
this
)
this
.
removeEventListener
(
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove_this
,
this
)
this
.
removeEventListener
(
MouseEvent
.
MOUSE_UP
,
this
.
onUp_this
,
this
)
this
.
removeEventListener
(
MouseEvent
.
MOUSE_UP
,
this
.
onUp_this
,
this
)
this
.
removeEventListener
(
MouseEvent
.
MOUSE_OUT
,
this
.
onUp_this
,
this
)
this
.
removeEventListener
(
MouseEvent
.
MOUSE_OUT
,
this
.
onUp_this
,
this
)
...
@@ -152,6 +168,15 @@ export class PlayScene extends Scene {
...
@@ -152,6 +168,15 @@ export class PlayScene extends Scene {
this
.
offsetY
=
0
this
.
offsetY
=
0
}
}
removeEvents
()
{
super
.
removeEvents
()
this
.
removeEventListener
(
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown_this
,
this
)
this
.
removeEventListener
(
MouseEvent
.
CLICK
,
this
.
onClick_exchangeBtn
,
this
)
this
.
removeEventListener
(
MouseEvent
.
CLICK
,
this
.
onClick_bombBtn
,
this
)
this
.
removeEventListener
(
MouseEvent
.
CLICK
,
this
.
onClick_filterBtn
,
this
)
}
async
checkMove
()
{
async
checkMove
()
{
if
(
Math
.
abs
(
this
.
offsetX
)
>
Math
.
abs
(
this
.
offsetY
))
{
if
(
Math
.
abs
(
this
.
offsetX
)
>
Math
.
abs
(
this
.
offsetY
))
{
// 横向移动
// 横向移动
...
@@ -302,11 +327,7 @@ export class PlayScene extends Scene {
...
@@ -302,11 +327,7 @@ export class PlayScene extends Scene {
gamewin
()
{
gamewin
()
{
// 游戏胜利
// 游戏胜利
}
console
.
log
(
"游戏胜利"
)
setScore
()
{
console
.
log
(
this
.
score
);
}
}
currMoveType
currMoveType
...
@@ -460,7 +481,6 @@ export class PlayScene extends Scene {
...
@@ -460,7 +481,6 @@ export class PlayScene extends Scene {
//一次性走完就让 i = 0 例如 2240 =》8000
//一次性走完就让 i = 0 例如 2240 =》8000
//i = 0 //此处不能 i -= 1 [8,2,2,4]会出问题
//i = 0 //此处不能 i -= 1 [8,2,2,4]会出问题
this
.
score
+=
arr
[
i
-
1
]
this
.
score
+=
arr
[
i
-
1
]
this
.
setScore
()
}
}
}
}
}
}
...
@@ -505,16 +525,4 @@ export class PlayScene extends Scene {
...
@@ -505,16 +525,4 @@ export class PlayScene extends Scene {
return
false
return
false
}
}
clone
(
obj
)
{
function
Fn
()
{
}
Fn
.
prototype
=
obj
;
var
o
=
new
Fn
();
for
(
var
a
in
o
)
{
if
(
typeof
o
[
a
]
==
"object"
)
{
o
[
a
]
=
this
.
clone
(
o
[
a
]);
}
}
return
o
;
}
}
}
\ No newline at end of file
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