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
a6b83c15
Commit
a6b83c15
authored
Apr 24, 2020
by
huangwenjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
y
parent
187d8fa1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
3 deletions
+56
-3
soundCtrl.ts
module/ctrls/soundCtrl.ts
+7
-0
res.json
resource/res.json
+1
-1
Check.ts
src/scenes/playScene/Check.ts
+28
-0
PlayScene.ts
src/scenes/playScene/PlayScene.ts
+20
-2
No files found.
module/ctrls/soundCtrl.ts
View file @
a6b83c15
...
...
@@ -77,6 +77,13 @@ export enum SoundType {
showPanel
=
'showPanel'
,
countDown
=
"countDown"
,
speedUp
=
"speedUp"
,
move
=
"move"
,
createEle
=
"createEle"
,
createEles
=
"createELes"
,
bomb
=
"bomb"
,
exchange
=
"exchange"
,
gameOver
=
"gameOver"
,
}
/**
...
...
resource/res.json
View file @
a6b83c15
...
...
@@ -9,7 +9,7 @@
"name"
:
"gameOverPanel"
},
{
"keys"
:
"bomb(1).png,bomb(10).png,bomb(11).png,bomb(12).png,bomb(13).png,bomb(14).png,bomb(15).png,bomb(16).png,bomb(17).png,bomb(18).png,bomb(19).png,bomb(2).png,bomb(20).png,bomb(3).png,bomb(4).png,bomb(5).png,bomb(6).png,bomb(7).png,bomb(8).png,bomb(9).png,bomb
Btn.png,bombTips.png,create1024.svga,create128.svga,create16.svga,create2048.svga,create256.svga,create32.svga,create4.svga,create512.svga,create64.svga,create8.svga,doFilterBtn.png,ele1024.png,ele128.png,ele16.png,ele2.png,ele2048.png,ele256.png,ele32.png,ele4.png,ele512.png,ele64.png,ele8.png,exchangeBtn.png,exchangeTips.png,filterBtn.png,filterTips.png,filting (1).png,filting (10).png,filting (11).png,filting (12).png,filting (13).png,filting (14).png,filting (15).png,filting (16).png,filting (17).png,filting (2).png,filting (3).png,filting (4).png,filting (5).png,filting (6).png,filting (7).png,filting (8).png,filting (9).png,focusTips.png,goBackBtn.png,guideArrow.png,guideFinger.png
,musicOff.png,musicOn.png,playBg.png,propBottom.png"
,
"keys"
:
"bomb(1).png,bomb(10).png,bomb(11).png,bomb(12).png,bomb(13).png,bomb(14).png,bomb(15).png,bomb(16).png,bomb(17).png,bomb(18).png,bomb(19).png,bomb(2).png,bomb(20).png,bomb(3).png,bomb(4).png,bomb(5).png,bomb(6).png,bomb(7).png,bomb(8).png,bomb(9).png,bomb
.mp3,bombBtn.png,bombTips.png,create1024.svga,create128.svga,create16.svga,create2048.svga,create256.svga,create32.svga,create4.svga,create512.svga,create64.svga,create8.svga,createEle.mp3,createEles.mp3,doFilterBtn.png,ele1024.png,ele128.png,ele16.png,ele2.png,ele2048.png,ele256.png,ele32.png,ele4.png,ele512.png,ele64.png,ele8.png,exchange.mp3,exchangeBtn.png,exchangeTips.png,filterBtn.png,filterTips.png,filting (1).png,filting (10).png,filting (11).png,filting (12).png,filting (13).png,filting (14).png,filting (15).png,filting (16).png,filting (17).png,filting (2).png,filting (3).png,filting (4).png,filting (5).png,filting (6).png,filting (7).png,filting (8).png,filting (9).png,focusTips.png,gameOver.mp3,goBackBtn.png,guideArrow.png,guideFinger.png,move.mp3
,musicOff.png,musicOn.png,playBg.png,propBottom.png"
,
"name"
:
"playScene"
},
{
...
...
src/scenes/playScene/Check.ts
View file @
a6b83c15
import
{
playSound
,
SoundType
}
from
'./../../../module/ctrls/soundCtrl'
;
export
const
noBlockLeft
=
(
x
,
y
,
yl
,
beforeArr
)
=>
{
if
(
y
>
yl
+
1
)
{
for
(
let
t
=
yl
-
1
;
t
<
y
;
t
++
)
{
...
...
@@ -68,4 +69,31 @@ export const noBlockBottom = (x, xb, y, beforeArr) => {
}
}
return
true
}
export
const
checkMusic
=
(
type
,
isPlay
)
=>
{
if
(
!
isPlay
)
{
return
}
switch
(
type
)
{
case
"move"
:
playSound
(
SoundType
.
move
)
break
case
"createEle"
:
playSound
(
SoundType
.
createEle
)
break
case
"createEles"
:
playSound
(
SoundType
.
createEles
)
break
case
"exchange"
:
playSound
(
SoundType
.
exchange
)
break
case
"bomb"
:
playSound
(
SoundType
.
bomb
)
break
case
"gameOver"
:
playSound
(
SoundType
.
gameOver
)
break
}
}
\ No newline at end of file
src/scenes/playScene/PlayScene.ts
View file @
a6b83c15
import
{
FrameAni
}
from
'./../../../engine/2d/ui/FrameAni'
;
import
{
MovieClip
}
from
'./../../../engine/2d/svga/MovieClip'
;
import
{
Shape
}
from
'./../../../engine/2d/graphics/Shape'
;
import
{
noBlockLeft
,
noBlockRight
,
noBlockTop
,
noBlockBottom
}
from
'./Check'
;
import
{
noBlockLeft
,
noBlockRight
,
noBlockTop
,
noBlockBottom
,
checkMusic
}
from
'./Check'
;
import
{
GDispatcher
}
from
'./../../../engine/2d/events/GDispatcher'
;
import
{
Button
}
from
'./../../../engine/2d/ui/Button'
;
import
{
GameEle
}
from
'./GameEle'
;
...
...
@@ -13,11 +13,14 @@ import { Container, Sprite } from '../../../engine/2d/display';
import
{
Graphics
}
from
'../../../engine/2d/graphics'
;
import
Tween
from
'../../../engine/tween/Tween'
;
import
{
RES
}
from
'../../../module/RES'
;
import
{
getTools
}
from
'../../commonNet'
export
class
PlayScene
extends
Scene
{
get
groupNames
()
{
return
[
"playScene"
]
}
constructor
()
{
gameData
constructor
(
data
)
{
super
()
this
.
gameData
=
data
}
start
()
{
...
...
@@ -48,6 +51,8 @@ export class PlayScene extends Scene {
return
this
.
_unlockScore
}
isPlayMusic
:
boolean
=
true
bg
:
Sprite
goBackBtn
:
Button
musicBtn
:
Button
...
...
@@ -372,6 +377,8 @@ export class PlayScene extends Scene {
this
.
removeAnis
()
checkMusic
(
"exchange"
,
this
.
isPlayMusic
)
// 交换动效
await
this
.
exchangeAni
()
// if (num0 == num1) {
...
...
@@ -398,6 +405,9 @@ export class PlayScene extends Scene {
this
.
removeChild
(
this
.
exchangeMask
)
this
.
removeAllClick
()
this
.
exchangeTargetPool
=
[]
getTools
()
this
.
exchanging
=
false
this
.
exchangeBtn
.
mouseEnable
=
true
if
(
!
this
.
isGameWin
())
...
...
@@ -507,6 +517,8 @@ export class PlayScene extends Scene {
showImage
.
scale
.
set
(
0.5
,
0.5
)
this
.
addChild
(
showImage
);
showImage
.
play
()
checkMusic
(
"bomb"
,
this
.
isPlayMusic
)
setTimeout
(()
=>
{
this
.
board
[
x
][
y
]
=
0
this
.
renderBoard
()
...
...
@@ -714,14 +726,17 @@ export class PlayScene extends Scene {
// 只有0
this
.
generateOneElement
()
}
this
.
moving
=
true
let
beforeArr
=
this
.
cloneArr
(
this
.
board
)
if
(
Math
.
abs
(
this
.
offsetX
)
>
Math
.
abs
(
this
.
offsetY
))
{
// 横向移动
if
(
this
.
offsetX
>
0
)
{
console
.
log
(
"右滑"
);
// 复制一份原先的数组
if
(
this
.
moveToRight
(
true
))
{
checkMusic
(
"move"
,
this
.
isPlayMusic
)
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
...
...
@@ -732,6 +747,7 @@ export class PlayScene extends Scene {
if
(
this
.
offsetX
<
0
)
{
console
.
log
(
"左滑"
)
if
(
this
.
moveToLeft
(
true
))
{
checkMusic
(
"move"
,
this
.
isPlayMusic
)
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
...
...
@@ -744,6 +760,7 @@ export class PlayScene extends Scene {
if
(
this
.
offsetY
>
0
)
{
console
.
log
(
"下滑"
)
if
(
this
.
moveToBottom
(
true
))
{
checkMusic
(
"move"
,
this
.
isPlayMusic
)
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
...
...
@@ -754,6 +771,7 @@ export class PlayScene extends Scene {
if
(
this
.
offsetY
<
0
)
{
console
.
log
(
"上滑"
)
if
(
this
.
moveToTop
(
true
))
{
checkMusic
(
"move"
,
this
.
isPlayMusic
)
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
...
...
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