Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DuibaGameTemplate
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
钱根
DuibaGameTemplate
Commits
999fd2d6
Commit
999fd2d6
authored
Mar 11, 2022
by
Master Q
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
11e1b71d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
22 deletions
+65
-22
upload.js
scripts/upload.js
+4
-0
Main.ts
src/Main.ts
+14
-7
ResJson.ts
src/ResJson.ts
+2
-1
Tools.ts
src/Tools.ts
+2
-1
IndexScene.ts
src/scenes/IndexScene.ts
+43
-13
No files found.
scripts/upload.js
View file @
999fd2d6
...
...
@@ -157,6 +157,10 @@ data.path = `https://yun.duiba.com.cn/db_games/${config.type}/${config.name}/${v
//写入目标文件夹,可配置,每个项目必须修改,或者直接和project的保持一致(淘宝项目文件固定后)
var endPath = '
.
/
src
/
';
var endFile = `export const ResJson = ${JSON.stringify(data, "", "
\
t")}`
endFile = endFile.replace(
`"path": "${data.path}"`,
`// eslint-disable-next-line
\
n
\
t"path": "${data.path}"`
);
fs.writeFileSync(endPath + "ResJson.ts", endFile);
...
...
src/Main.ts
View file @
999fd2d6
...
...
@@ -24,6 +24,12 @@ export class Main {
private
_pause
:
boolean
;
private
canvas
:
HTMLCanvasElement
changeGamePageConfig
(
PAGE
)
{
PAGE
&&
(
Tools
.
PAGE
=
PAGE
);
}
gameSceneInitPromise
:
Promise
<
any
>
;
constructor
(
canvas
:
HTMLCanvasElement
,
PAGE
)
{
PAGE
&&
(
Tools
.
PAGE
=
PAGE
);
var
sysInfo
;
...
...
@@ -156,17 +162,12 @@ export class Main {
// 皮肤配置加载
RES
.
loadSkinConfig
(
SkinJson
);
console
.
log
(
"初始化皮肤配置完成"
)
// 加载完美 icon 资源
await
RES
.
loadGroup
(
'excellent_icon'
)
// 加载通用资源
await
RES
.
loadGroup
(
"common"
);
console
.
log
(
"通用资源加载完成"
)
// h5环境时,隐藏加载中
if
(
FYGE
.
getEnv
()
==
"web"
&&
document
.
getElementById
(
"__loading__"
))
document
.
getElementById
(
"__loading__"
).
style
.
display
=
"none"
;
console
.
log
(
'getGlobalData'
)
await
Tools
.
getGlobalData
()
// const baseSuccess = await Tools.getActivityBaseInfo();
// if (!baseSuccess) {
// showToast("获取活动信息失败");
...
...
@@ -178,9 +179,15 @@ export class Main {
// showToast("获取游戏信息失败");
// return;
// }
let
gameSceneInitResolve
:
any
;
this
.
gameSceneInitPromise
=
new
Promise
(
r
=>
{
gameSceneInitResolve
=
r
})
// vtodo 是否是新手
changeScene
(
IndexScene
);
changeScene
(
IndexScene
,
{
sceneData
:
11
,
gameSceneInitResolve
:
gameSceneInitResolve
});
}
}
...
...
src/ResJson.ts
View file @
999fd2d6
...
...
@@ -376,5 +376,6 @@ export const ResJson = {
}
}
],
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/1646360490/resource/"
// eslint-disable-next-line
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/1646963505/resource/"
}
\ No newline at end of file
src/Tools.ts
View file @
999fd2d6
...
...
@@ -40,7 +40,8 @@ export class Tools {
public
static
PAGE
=
{
isNewGuy
:
false
,
countDownNum
:
30
countDownNum
:
30
,
musicStatus
:
false
};
/**
...
...
src/scenes/IndexScene.ts
View file @
999fd2d6
...
...
@@ -16,6 +16,7 @@ function randomNum(m: number, n: number) {
const
GameEvent
=
{
GAME_START
:
'GAME_START'
,
GAME_OVER
:
'GAME_OVER'
,
GAME_BGM
:
'GAME_BGM'
,
}
class
CountDownBoard
extends
FYGE
.
Container
{
...
...
@@ -331,7 +332,7 @@ const GameEles: GameEleInfer[] = [
{
resource
:
'boomSprit.png'
,
probability
:
10
,
score
:
-
1
,
score
:
0
,
}
]
...
...
@@ -354,9 +355,10 @@ export default class IndexScene extends Scene {
}
set
musicStatus
(
v
)
{
if
(
this
.
_musicStatus
===
v
)
return
//
if (this._musicStatus === v) return
this
.
_musicStatus
=
v
this
.
musicBtn
.
texture
=
RES
.
getRes
(
v
?
'music-on.png'
:
'music-off.png'
)
GDispatcher
.
dispatchEvent
(
GameEvent
.
GAME_BGM
,
v
)
}
get
score
()
{
...
...
@@ -387,12 +389,14 @@ export default class IndexScene extends Scene {
this
.
initCountDown
()
this
.
initScoreBoard
()
this
.
onInitGamer
()
this
.
initMusicBtn
(
true
)
this
.
initMusicBtn
(
Tools
.
PAGE
.
musicStatus
)
// this.onInitFallGameEle()
}
async
start
(
data
?:
any
)
{
super
.
start
()
// 完成scene的初始化
data
.
gameSceneInitResolve
()
}
/**
...
...
@@ -424,7 +428,6 @@ export default class IndexScene extends Scene {
this
.
musicBtn
=
UI
.
Btn
(
this
,
isOn
?
'music-on.png'
:
'music-off.png'
,
()
=>
{
this
.
musicStatus
=
!
this
.
musicStatus
},
this
,
660
,
layers
.
stageOffsetY
+
200
)
this
.
musicStatus
=
isOn
}
/**
...
...
@@ -476,12 +479,12 @@ export default class IndexScene extends Scene {
const
stepSprite
=
UI
.
Sp
(
NewGuyCont
,
'step1.png'
)
let
step
=
1
function
showStepImg
()
{
stepSprite
.
texture
=
RES
.
getRes
(
`step
${
step
}
.png`
)
step
++
if
(
step
>
4
)
{
NewGuyCont
.
destroy
()
r
()
}
stepSprite
.
texture
=
RES
.
getRes
(
`step
${
step
}
.png`
)
step
++
}
showStepImg
()
NewGuyCont
.
addEventListener
(
FYGE
.
MouseEvent
.
CLICK
,
()
=>
{
...
...
@@ -490,16 +493,24 @@ export default class IndexScene extends Scene {
})
}
/**
* 游戏初始化
*/
onGameInit
()
{
this
.
score
=
0
this
.
musicStatus
=
Tools
.
PAGE
.
musicStatus
this
.
recoverGameEles
()
this
.
onInitGamer
()
}
/**
* 游戏开始
*/
async
onGameStart
()
{
this
.
score
=
0
this
.
onGameInit
()
if
(
Tools
.
PAGE
.
isNewGuy
)
{
await
this
.
onShowNewGuySteps
()
}
this
.
recoverGameEles
()
this
.
onInitGamer
()
await
this
.
onShowPreCountDown
()
this
.
GameStatus
=
1
this
.
CountDownCont
.
restart
()
...
...
@@ -522,7 +533,7 @@ export default class IndexScene extends Scene {
onInitGamer
()
{
if
(
!
this
.
RobotGameEle
)
{
this
.
RobotGameEle
=
this
.
addChild
(
new
GameEleSprit
(
'robotGamer.png'
))
this
.
RobotGameEle
.
addPythicCont
(
new
RectPythicCont
(
50
,
190
,
100
,
60
),
tru
e
)
this
.
RobotGameEle
.
addPythicCont
(
new
RectPythicCont
(
50
,
190
,
100
,
60
),
fals
e
)
}
this
.
RobotGameEle
.
position
.
set
(
375
-
this
.
RobotGameEle
.
width
/
2
,
1100
)
}
...
...
@@ -531,7 +542,7 @@ export default class IndexScene extends Scene {
* 初始化游戏掉落元素
*/
onInitFallGameEle
()
{
this
.
spl
=
randomNum
(
4
0
,
300
)
this
.
spl
=
randomNum
(
8
0
,
300
)
const
curr
=
this
.
currGameEleResource
const
currResource
:
GameEleResource
=
curr
.
resource
const
currGameELe
=
GPool
.
takeOut
<
GameEleSprit
>
(
currResource
)
||
this
.
addChild
(
new
GameEleSprit
(
currResource
,
curr
.
score
))
...
...
@@ -539,7 +550,7 @@ export default class IndexScene extends Scene {
this
.
gameElesList
.
push
(
currGameELe
)
currGameELe
.
position
.
set
(
randomNum
(
this
.
axisX
[
0
],
this
.
axisX
[
1
]),
layers
.
stageOffsetY
)
if
(
!
currGameELe
.
pythicCont
)
{
const
debug
=
tru
e
const
debug
=
fals
e
if
(
currResource
===
'bellSprit.png'
)
{
currGameELe
.
addPythicCont
(
new
CirclePythicCont
(
36
,
40
,
40
),
debug
)
}
else
if
(
currResource
===
'orangeSprit.png'
)
{
...
...
@@ -606,10 +617,27 @@ export default class IndexScene extends Scene {
this
.
gameElesList
.
length
=
0
}
playGameEleSounds
(
resource
:
string
)
{
if
(
!
this
.
musicStatus
&&
resource
!==
'boomSprit.png'
)
{
return
}
const
kv
=
{
'bellSprit.png'
:
'bell'
,
'orangeSprit.png'
:
'orange'
,
'boomSprit.png'
:
'boom'
}
GDispatcher
.
dispatchEvent
(
GameEvent
.
GAME_BGM
,
{
isOn
:
true
,
key
:
kv
[
resource
],
loop
:
false
})
}
_cacheLen
:
number
=
0
frameUpdate
()
{
if
(
!
this
.
GameStatus
)
return
const
delta
=
this
.
clock
.
getDelta
()
if
(
delta
>
100
)
return
const
sdt
=
this
.
speed
*
delta
this
.
_cacheLen
+=
sdt
if
(
this
.
_cacheLen
>
this
.
spl
)
{
...
...
@@ -628,9 +656,11 @@ export default class IndexScene extends Scene {
if
(
onCollsionJudge
(
item
.
pythicCont
.
commonPythicPos
,
this
.
RobotGameEle
.
pythicCont
.
commonPythicPos
))
{
item
.
visible
=
false
GPool
.
takeIn
(
item
.
resource
,
item
)
// 播放音效
this
.
playGameEleSounds
(
item
.
resource
)
this
.
gameElesList
.
splice
(
i
,
1
)
// console.log(item)
if
(
item
.
score
==
-
1
)
{
if
(
item
.
score
==
0
)
{
console
.
log
(
'boom'
,
item
)
this
.
onGameOver
()
}
...
...
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