Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
JsxForFYGETemplate
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
钱根
JsxForFYGETemplate
Commits
ee62695e
Commit
ee62695e
authored
Dec 13, 2022
by
Master Q
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏基本逻辑确定
parent
febedac1
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
578 additions
and
52 deletions
+578
-52
index.html
index.html
+7
-1
clockBack.png
resource/GameScene/clockBack.png
+0
-0
sp_boom.png
resource/GameScene/sp_boom.png
+0
-0
sp_milk.png
resource/GameScene/sp_milk.png
+0
-0
res.json
resource/res.json
+1
-1
mergeJs.js
scripts/mergeJs.js
+1
-1
ResJson.ts
src/ResJson.ts
+177
-5
DreamTextField.tsx
src/components/DreamTextField/DreamTextField.tsx
+9
-1
index.tsx
src/index.tsx
+6
-4
GameConfig.ts
src/scenes/GameScene/GameConfig.ts
+147
-23
GameEvents.ts
src/scenes/GameScene/GameEvents.ts
+3
-0
GameScene.tsx
src/scenes/GameScene/GameScene.tsx
+115
-12
Platform.tsx
src/scenes/GameScene/Platform.tsx
+41
-0
SpClock.tsx
src/scenes/GameScene/SpClock.tsx
+69
-0
Tools.ts
src/tools/Tools.ts
+2
-4
No files found.
index.html
View file @
ee62695e
...
...
@@ -43,7 +43,11 @@
}
</style>
<!-- <script src="//yun.duiba.com.cn/db_games/libs0924/fyge2020.min.js" crossorigin="anonymous"></script> -->
<!-- 渲染引擎 -->
<script
src=
"//yun.duiba.com.cn/db_games/libs0924/fyge2044.min.js"
crossorigin=
"anonymous"
></script>
<!-- svga解析库 -->
<script
src=
"//yun.duiba.com.cn/db_games/libs0924/svgaParser.minWeb.js"
crossorigin=
"anonymous"
></script>
</head>
<body>
<div
class=
"ss"
style=
"line-height:0;font-size:0;position: absolute;"
>
...
...
@@ -65,7 +69,9 @@
const
canvas
=
document
.
getElementById
(
'stage'
)
canvas
.
width
=
document
.
body
.
clientWidth
*
(
window
.
devicePixelRatio
||
1
)
canvas
.
height
=
document
.
body
.
clientHeight
*
(
window
.
devicePixelRatio
||
1
)
new
Main
(
canvas
)
new
Main
(
canvas
,
{
isFirstGame
:
true
})
})
</script>
...
...
resource/GameScene/clockBack.png
0 → 100644
View file @
ee62695e
11.8 KB
resource/GameScene/sp_boom.png
0 → 100644
View file @
ee62695e
8.97 KB
resource/GameScene/sp_milk.png
0 → 100644
View file @
ee62695e
14.9 KB
resource/res.json
View file @
ee62695e
{
"groups"
:
[
{
"keys"
:
"GSB.png,
platform.png,rabbit.png,scoreBoardBac
k.png"
,
"keys"
:
"GSB.png,
clockBack.png,platform.png,rabbit.png,scoreBoardBack.png,sp_boom.png,sp_mil
k.png"
,
"name"
:
"GameScene"
},
{
...
...
scripts/mergeJs.js
View file @
ee62695e
...
...
@@ -12,6 +12,6 @@ fs.writeFileSync(endPath + "output.js",
// 'import * as FYGE from "fyge";\n' +//以后改成这个
// 'import * as SvgaParser from "svga-parser";\n' +
'/* eslint-disable */
\
n'
+
'const FYGE = require("./fyge.min.js");
\
n'
+
//
'const FYGE = require("./fyge.min.js");\n' +
fs
.
readFileSync
(
"./output.js"
));
console
.
log
(
"js生成"
)
src/ResJson.ts
View file @
ee62695e
export
const
ResJson
=
{
"groups"
:
[
{
"keys"
:
"GSB.png,platform.png,rabbit.png,scoreBoardBack.png"
,
"name"
:
"GameScene"
"keys"
:
"GSB.png,clockBack.png,platform.png,rabbit.png,scoreBoardBack.png,sp_boom.png,sp_milk.png"
,
"name"
:
"GameScene"
,
"atlas"
:
{
"GSB.png"
:
{
"x"
:
2
,
"y"
:
2
,
"w"
:
750
,
"h"
:
1624
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
750
,
"sh"
:
1624
,
"ro"
:
false
},
"rabbit.png"
:
{
"x"
:
754
,
"y"
:
2
,
"w"
:
110
,
"h"
:
218
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
110
,
"sh"
:
218
,
"ro"
:
false
},
"scoreBoardBack.png"
:
{
"x"
:
754
,
"y"
:
222
,
"w"
:
193
,
"h"
:
81
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
193
,
"sh"
:
81
,
"ro"
:
true
},
"platform.png"
:
{
"x"
:
754
,
"y"
:
417
,
"w"
:
142
,
"h"
:
52
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
142
,
"sh"
:
52
,
"ro"
:
true
},
"sp_boom.png"
:
{
"x"
:
754
,
"y"
:
561
,
"w"
:
94
,
"h"
:
99
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
94
,
"sh"
:
99
,
"ro"
:
true
},
"sp_milk.png"
:
{
"x"
:
754
,
"y"
:
657
,
"w"
:
93
,
"h"
:
93
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
93
,
"sh"
:
93
,
"ro"
:
false
},
"clockBack.png"
:
{
"x"
:
754
,
"y"
:
752
,
"w"
:
80
,
"h"
:
91
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
80
,
"sh"
:
91
,
"ro"
:
true
}
}
},
{
"keys"
:
"Guide1.png,Guide2.png,Guide3.png,Guide4.png"
,
"name"
:
"NewGuyScene"
"name"
:
"NewGuyScene"
,
"atlas"
:
{
"Guide1.png"
:
{
"x"
:
2
,
"y"
:
2
,
"w"
:
750
,
"h"
:
1624
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
750
,
"sh"
:
1624
,
"ro"
:
false
},
"Guide2.png"
:
{
"x"
:
754
,
"y"
:
2
,
"w"
:
750
,
"h"
:
1624
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
750
,
"sh"
:
1624
,
"ro"
:
false
},
"Guide3.png"
:
{
"x"
:
1506
,
"y"
:
2
,
"w"
:
750
,
"h"
:
1624
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
750
,
"sh"
:
1624
,
"ro"
:
false
},
"Guide4.png"
:
{
"x"
:
2
,
"y"
:
1628
,
"w"
:
750
,
"h"
:
1624
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
750
,
"sh"
:
1624
,
"ro"
:
true
}
}
},
{
"keys"
:
"closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png"
,
"name"
:
"common"
"name"
:
"common"
,
"atlas"
:
{
"waitingBg.png"
:
{
"x"
:
2
,
"y"
:
2
,
"w"
:
160
,
"h"
:
180
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
160
,
"sh"
:
180
,
"ro"
:
false
},
"giftBoxIcon.png"
:
{
"x"
:
164
,
"y"
:
2
,
"w"
:
127
,
"h"
:
125
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
127
,
"sh"
:
125
,
"ro"
:
true
},
"waitingRot.png"
:
{
"x"
:
2
,
"y"
:
184
,
"w"
:
56
,
"h"
:
56
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
56
,
"sh"
:
56
,
"ro"
:
false
},
"closebtn.png"
:
{
"x"
:
60
,
"y"
:
184
,
"w"
:
52
,
"h"
:
52
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
52
,
"sh"
:
52
,
"ro"
:
false
}
}
}
],
"path"
:
"./resource/"
// eslint-disable-next-line
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/1670923535/resource/"
}
\ No newline at end of file
src/components/DreamTextField/DreamTextField.tsx
View file @
ee62695e
...
...
@@ -9,6 +9,8 @@ export const DreamTextField: OriginalElementWidthEvents<{
bold
?:
boolean
,
textHeight
?:
number
verticalAlign
?:
FYGE
.
VERTICAL_ALIGN
stroke
?:
number
strokeColor
?:
string
},
FYGE
.
TextField
>
=
({
text
,
color
=
'#000000'
,
...
...
@@ -17,7 +19,9 @@ export const DreamTextField: OriginalElementWidthEvents<{
align
=
FYGE
.
TEXT_ALIGN
.
CENTER
,
bold
=
false
,
textHeight
,
verticalAlign
=
FYGE
.
VERTICAL_ALIGN
.
MIDDLE
verticalAlign
=
FYGE
.
VERTICAL_ALIGN
.
MIDDLE
,
stroke
=
0
,
strokeColor
=
'#000000'
})
=>
{
const
textIns
=
new
FYGE
.
TextField
()
textIns
.
fillColor
=
color
;
...
...
@@ -28,5 +32,9 @@ export const DreamTextField: OriginalElementWidthEvents<{
textIns
.
bold
=
bold
textHeight
&&
(
textIns
.
textHeight
=
textHeight
)
textIns
.
verticalAlign
=
verticalAlign
textIns
.
stroke
=
stroke
textIns
.
strokeColor
=
strokeColor
return
textIns
}
\ No newline at end of file
src/index.tsx
View file @
ee62695e
...
...
@@ -19,8 +19,11 @@ import getEnv = FYGE.getEnv;
*/
export
const
GDispatcher
=
new
EventDispatcher
();
export
{
G_Events
}
from
'./scenes/GameScene/GameEvents'
export
const
loadAllGroups
=
async
function
()
{
FYGE
.
setEnv
(
'tb'
)
RES
.
loadConfig
(
ResJson
)
await
RES
.
loadAllGroup
()
}
...
...
@@ -35,8 +38,7 @@ export class Main {
constructor
(
canvas
:
HTMLCanvasElement
,
config
:
{
isFirstGame
:
boolean
,
liveCard
:
number
isFirstGame
:
boolean
},
desWidth
=
750
,
desHeight
=
1624
,
...
...
@@ -108,7 +110,7 @@ export class Main {
RES
.
loadConfig
(
ResJson
)
await
RES
.
loadGroup
(
'common'
)
SceneController
.
changeScene
(
GameScene
)
SceneController
.
changeScene
(
Tools
.
PageData
.
isFirstGame
?
NewGuyScene
:
GameScene
)
}
initWebEvent
(){
...
...
src/scenes/GameScene/GameConfig.ts
View file @
ee62695e
import
{
layers
}
from
"../../modules/layers"
;
// type 1 正常 2必出道具 3必出炸弹 4 随机出 道具 5 随机出炸弹
// 一行中 最多一个炸弹,这样配合 概率就不会导致出现死局
export
const
GameConfig
=
{
debugger
:
true
,
sp_p
:
0.3
,
// 出现道具的 概率
sp_b
:
0.8
,
// 出现炸弹的概率
offsetYLen
:
180
,
offsetXLen
:
150
,
// 格子间隔
offsetXLen
:
150
,
// 格子间隔
rowNum
:
30
,
// 单个地图的显示 行数
speed
:
100
,
// 卷轴速度
mapChangeAddSpeed
:
10
,
// 切换地图就会 增加速度
renderMapScreenNum
:
200
,
//当卷轴 移动到视窗上面多少 会去生成地图
rabbitConfig
:
{
offsetX
:
10
,
offsetY
:
-
203
,
},
DecisionLine
:
[
// 判定线 当前屏幕显示区域
300
,
layers
.
stageHeight
// 这里个需要后续设定
DecisionLine
:
[
// 判定线 当前屏幕显示区域
300
,
layers
.
stageHeight
,
// 这里个需要后续设定
],
landPlatformScore
:
2
,
// 平台上的分数
spCountTime
:
3100
,
//道具倒计时
boxColNum
:
5
,
// 几列格子
mapList
:
[
{
initPos
:
{
x
:
2
,
y
:
26
y
:
26
,
},
boxMap
:
[
[
0
,
1
,
0
,
1
,
1
],
[
0
,
1
,
1
,
0
,
0
],
[
1
,
0
,
0
,
1
,
0
],
[
0
,
1
,
0
,
1
,
3
],
[
0
,
4
,
1
,
0
,
0
],
[
4
,
0
,
0
,
5
,
0
],
[
0
,
1
,
1
,
0
,
1
],
[
1
,
1
,
0
,
1
,
0
],
[
4
,
3
,
0
,
1
,
0
],
[
0
,
1
,
1
,
0
,
0
],
[
1
,
0
,
0
,
0
,
1
],
[
5
,
0
,
0
,
0
,
1
],
[
1
,
0
,
1
,
1
,
1
],
[
0
,
1
,
0
,
0
,
1
],
[
1
,
0
,
1
,
0
,
0
],
[
0
,
1
,
0
,
1
,
0
],
[
0
,
1
,
0
,
0
,
5
],
[
1
,
0
,
1
,
0
,
0
],
[
0
,
0
,
1
,
0
,
1
],
[
1
,
1
,
0
,
1
,
1
],
[
0
,
1
,
0
,
5
,
0
],
[
5
,
0
,
1
,
0
,
0
],
[
0
,
0
,
3
,
0
,
5
],
[
1
,
1
,
0
,
5
,
1
],
[
0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1
,
1
],
[
0
,
1
,
1
,
0
,
1
],
[
1
,
0
,
0
,
1
,
0
],
[
0
,
1
,
1
,
0
,
1
],
[
1
,
1
,
1
,
1
,
1
],
[
0
,
1
,
0
,
1
,
0
],
[
0
,
1
,
4
,
1
,
0
],
[
1
,
1
,
3
,
1
,
1
],
[
0
,
5
,
0
,
5
,
0
],
[
0
,
0
,
1
,
0
,
0
],
[
0
,
0
,
1
,
1
,
1
],
[
0
,
1
,
1
,
5
,
2
],
[
1
,
0
,
0
,
0
,
0
],
[
0
,
1
,
0
,
1
,
0
],
[
4
,
0
,
0
,
0
,
1
],
[
1
,
0
,
4
,
4
,
1
],
[
1
,
0
,
0
,
0
,
1
],
[
3
,
0
,
2
,
0
,
1
],
[
1
,
0
,
0
,
0
,
0
],
[
0
,
1
,
0
,
1
,
0
],
[
1
,
0
,
2
,
0
,
1
],
[
5
,
0
,
0
,
0
,
5
],
[
0
,
1
,
0
,
1
,
0
],
[
0
,
0
,
1
,
0
,
0
],
[
0
,
4
,
0
,
4
,
0
],
[
1
,
3
,
1
,
1
,
1
],
[
1
,
0
,
2
,
0
,
1
],
[
0
,
1
,
0
,
1
,
0
],
],
},
],
...
...
src/scenes/GameScene/GameEvents.ts
0 → 100644
View file @
ee62695e
export
const
G_Events
=
{
GameOver
:
'GameOver'
}
\ No newline at end of file
src/scenes/GameScene/GameScene.tsx
View file @
ee62695e
import
{
GDispatcher
}
from
"../.."
;
import
{
DreamContainer
}
from
"../../components/DreamContainer/DreamContainer"
;
import
{
DreamShape
}
from
"../../components/DreamShape/DreamShape"
;
import
{
DreamSprite
}
from
"../../components/DreamSprite/DreamSprite"
;
...
...
@@ -7,9 +8,11 @@ import { RES } from "../../modules/RES";
import
{
UsePreload
}
from
"../../modules/UseDecorator/usePreload"
;
import
{
PromiseAwait
}
from
"../../tools/Tools"
;
import
{
GameConfig
}
from
"./GameConfig"
;
import
{
G_Events
}
from
"./GameEvents"
;
import
{
Platform
}
from
"./Platform"
;
import
{
RabbitPlayer
}
from
"./Player"
;
import
{
ScoreBoard
}
from
"./ScoreBoard"
;
import
{
SpClock
}
from
"./SpClock"
;
type
Pos
=
{
x
:
number
,
...
...
@@ -21,6 +24,10 @@ const {
}
=
GameConfig
const
mapHeight
=
rowNum
*
offsetYLen
function
randomPro
(
n
:
number
)
{
return
Math
.
random
()
<
n
}
@
UsePreload
({
preAction
:
async
function
()
{
await
RES
.
loadGroup
(
'GameScene'
)
...
...
@@ -46,7 +53,10 @@ export class GameScene extends Dream.RenderContainer {
rabbitPos
:
Pos
rabbitContainer
:
FYGE
.
Container
// 兔子Container
rabbitCloneContainer
:
FYGE
.
Container
// 兔子的克隆体 做创屏幕动画的
rabbitBoxMap
:
number
[][]
=
[]
// 兔子地图map
rabbitBoxMap
:
Platform
[][]
=
[]
// 兔子地图map
ScoreBoardIns
:
ScoreBoard
// 当前分数面板
SpClockIns
:
SpClock
// 道具倒计时
double
:
number
=
1
// 是否双倍
set
dir
(
v
:
number
)
{
this
.
rabbitContainer
.
scaleX
=
v
...
...
@@ -56,9 +66,32 @@ export class GameScene extends Dream.RenderContainer {
didRendered
():
void
{
this
.
renderMap
(
true
)
this
.
initEvents
()
this
.
onGameStart
()
}
unMount
():
void
{
this
.
removeEvents
()
}
initEvents
()
{
// 测试地图
document
.
body
.
addEventListener
(
'keydown'
,
(
e
)
=>
{
const
keyCode
=
e
.
code
console
.
log
(
keyCode
)
if
(
keyCode
==
'ArrowDown'
)
{
this
.
onGameStart
()
}
else
{
this
.
onGameOver
()
}
})
}
removeEvents
()
{
}
onGameStart
()
{
GameConfig
.
DecisionLine
=
[
180
,
...
...
@@ -77,9 +110,14 @@ export class GameScene extends Dream.RenderContainer {
this
.
isPause
=
false
}
/**
* 游戏结束
*/
onGameOver
()
{
FYGE
.
Tween
.
removeTweens
(
this
.
rabbitContainer
)
this
.
isPause
=
true
GDispatcher
.
dispatchEvent
(
G_Events
.
GameOver
,
this
.
ScoreBoardIns
.
score
)
}
/**
...
...
@@ -87,9 +125,9 @@ export class GameScene extends Dream.RenderContainer {
* @param init 是否是初始化
*/
renderMap
(
init
:
boolean
=
false
)
{
// TODO 随机
console
.
info
(
'=========render map ==========='
)
const
mapConfig
=
GameConfig
.
mapList
[
0
]
const
mapConfig
=
GameConfig
.
mapList
[
Math
.
random
()
*
GameConfig
.
mapList
.
length
>>
0
]
const
{
rowNum
,
offsetYLen
...
...
@@ -101,22 +139,56 @@ export class GameScene extends Dream.RenderContainer {
this
.
rabbitPos
.
y
+=
rowNum
}
// 地图平台数组
const
mapPlatform
:
Platform
[][]
=
[]
this
.
GameMapContainer
.
addChildAt
(
<
DreamContainer
className=
"mapContainer"
inlineProps=
{
{
y
:
this
.
mapCount
*
rowNum
*
offsetYLen
*
-
1
}
}
>
{
mapBoxes
.
map
((
rowItem
,
rowIndex
)
=>
{
const
rowArr
:
any
[]
=
mapPlatform
[
rowIndex
]
=
[]
let
boomflag
=
false
// 一行就让出一个炸弹吧
let
clockflag
=
false
// 一行最多一个 道具吧
return
(
<
DreamContainer
inlineProps=
{
{
y
:
rowIndex
*
GameConfig
.
offsetYLen
}
}
>
{
rowItem
.
map
((
colItem
,
colIndex
)
=>
{
// TODO type
return
(
colItem
?
<
Platform
type=
{
1
}
x=
{
colIndex
*
offsetXLen
}
/>
:
undefined
)
if
(
colItem
==
4
)
{
colItem
=
randomPro
(
GameConfig
.
sp_p
)
?
2
:
1
}
else
if
(
colItem
==
5
)
{
colItem
=
randomPro
(
GameConfig
.
sp_b
)
?
3
:
1
}
// 一行中还是 随机到 炸弹就变成平台
if
(
colItem
==
3
)
{
if
(
boomflag
)
{
colItem
=
1
}
else
{
boomflag
=
true
}
}
if
(
colItem
==
2
)
{
if
(
clockflag
)
{
colItem
=
1
}
else
{
clockflag
=
true
}
}
if
(
colItem
)
{
return
<
Platform
ref=
{
el
=>
{
rowArr
[
colIndex
]
=
el
}
}
pos=
{
[
rowIndex
,
colIndex
]
}
type=
{
colItem
}
x=
{
colIndex
*
offsetXLen
}
/>
}
else
{
rowArr
[
colIndex
]
=
undefined
return
undefined
}
})
}
</
DreamContainer
>
...
...
@@ -126,8 +198,9 @@ export class GameScene extends Dream.RenderContainer {
</
DreamContainer
>
,
0
)
this
.
mapCount
+=
1
this
.
rabbitBoxMap
.
unshift
(...
mapBoxes
)
console
.
log
(
this
.
rabbitBoxMap
)
// 增加速度
GameConfig
.
speed
+=
GameConfig
.
mapChangeAddSpeed
this
.
rabbitBoxMap
.
unshift
(...
mapPlatform
)
}
/**
...
...
@@ -157,7 +230,7 @@ export class GameScene extends Dream.RenderContainer {
const
now
=
Date
.
now
()
const
st
=
(
now
-
this
.
lastTime
)
/
1000
this
.
lastTime
=
now
if
(
st
>
1
)
{
if
(
st
>
0.2
)
{
return
}
this
.
GameReelContainer
.
y
+=
GameConfig
.
speed
*
st
...
...
@@ -203,7 +276,8 @@ export class GameScene extends Dream.RenderContainer {
const
willX
=
(
_willX
+
GameConfig
.
boxColNum
)
%
GameConfig
.
boxColNum
let
shouldY
=
ray
-
(
screenRY
<
GameConfig
.
DecisionLine
[
0
]
?
0
:
1
)
// console.log('========',shouldY, '\n===stageX===\n', stageX)
while
(
!
rabbitBoxMap
[
shouldY
][
willX
])
{
let
landPlatform
:
Platform
while
(
!
(
landPlatform
=
rabbitBoxMap
[
shouldY
][
willX
]))
{
shouldY
+=
1
if
(
shouldY
>=
rabbitBoxMap
.
length
-
1
)
{
break
...
...
@@ -252,12 +326,39 @@ export class GameScene extends Dream.RenderContainer {
this
.
rabbitContainer
=
rabbitCloneContainer
this
.
rabbitCloneContainer
=
rabbitContainer
}
this
.
onPlatformLand
(
landPlatform
)
resolve
()
})
})
}
/**
* 平台判断
* @param platform
*/
onPlatformLand
(
platform
:
Platform
)
{
platform
.
onLand
((
type
:
number
,
s
:
number
)
=>
{
if
(
type
==
3
)
{
return
this
.
onGameOver
()
}
else
if
(
type
==
2
)
{
this
.
double
=
2
this
.
SpClockIns
.
onShowCountDown
(()
=>
{
this
.
double
=
1
})
}
this
.
onAddScore
(
s
)
})
}
/**
* 添加分数
* @param s
*/
onAddScore
(
s
:
number
)
{
this
.
ScoreBoardIns
.
score
+=
s
*
this
.
double
}
GameJudgeFrame
()
{
if
(
this
.
isPause
)
return
// 当前兔子在屏幕上的 y
...
...
@@ -285,7 +386,9 @@ export class GameScene extends Dream.RenderContainer {
</
DreamContainer
>
<
ScoreBoard
/>
<
ScoreBoard
ref=
{
(
el
:
ScoreBoard
)
=>
this
.
ScoreBoardIns
=
el
}
/>
<
SpClock
ref=
{
(
el
:
SpClock
)
=>
this
.
SpClockIns
=
el
}
/>
</
DreamContainer
>
)
}
...
...
src/scenes/GameScene/Platform.tsx
View file @
ee62695e
import
{
DreamContainer
}
from
"../../components/DreamContainer/DreamContainer"
;
import
{
DreamSprite
}
from
"../../components/DreamSprite/DreamSprite"
;
import
{
DreamTextField
}
from
"../../components/DreamTextField/DreamTextField"
;
import
Dream
from
"../../Dream"
;
import
{
fadeOutUpFactory
}
from
"../../modules/animations"
;
import
{
RES
}
from
"../../modules/RES"
;
import
{
GameConfig
}
from
"./GameConfig"
;
export
class
Platform
extends
Dream
.
RenderContainer
<
{
type
:
number
// 1 就是默认 2 道具 3 炸弹
x
:
number
pos
?:
[
number
,
number
]
}
>
{
private
isLanded
:
boolean
=
false
// 是否被踩过
private
spCont
:
FYGE
.
Container
onLand
(
cb
?:
(
type
:
number
,
s
:
number
)
=>
void
)
{
if
(
this
.
isLanded
)
return
this
.
isLanded
=
true
if
(
this
.
spCont
)
{
fadeOutUpFactory
(
500
)(
this
.
spCont
)
}
cb
&&
cb
(
this
.
props
.
type
,
GameConfig
.
landPlatformScore
)
}
/**
* 渲染道具
* @returns
*/
renderSp
()
{
if
(
this
.
props
.
type
==
2
)
{
return
this
.
spCont
=
<
DreamSprite
inlineProps=
{
{
x
:
28
,
y
:
-
100
}
}
src=
{
RES
.
getRes
(
'sp_milk.png'
)
}
/>
}
else
if
(
this
.
props
.
type
==
3
)
{
return
this
.
spCont
=
<
DreamSprite
inlineProps=
{
{
x
:
20
,
y
:
-
90
}
}
src=
{
RES
.
getRes
(
'sp_boom.png'
)
}
/>
}
}
render
()
{
const
backRes
=
RES
.
getRes
(
'platform.png'
)
return
(
...
...
@@ -16,6 +49,14 @@ export class Platform extends Dream.RenderContainer<{
<
DreamSprite
src=
{
backRes
}
inlineProps=
{
{
x
:
2
}
}
/>
{
this
.
renderSp
()
}
{
GameConfig
.
debugger
&&
this
.
props
.
pos
&&
(
<
DreamTextField
text=
{
this
.
props
.
pos
.
join
(
','
)
}
/>
)
}
</
DreamContainer
>
)
}
...
...
src/scenes/GameScene/SpClock.tsx
0 → 100644
View file @
ee62695e
import
{
DreamContainer
}
from
"../../components/DreamContainer/DreamContainer"
;
import
{
DreamSprite
}
from
"../../components/DreamSprite/DreamSprite"
;
import
{
DreamTextField
}
from
"../../components/DreamTextField/DreamTextField"
;
import
Dream
from
"../../Dream"
;
import
{
layers
}
from
"../../modules/layers"
;
import
{
RES
}
from
"../../modules/RES"
;
import
{
GameConfig
}
from
"./GameConfig"
;
export
class
SpClock
extends
Dream
.
RenderContainer
{
RoleCont
:
FYGE
.
Container
CountText
:
FYGE
.
TextField
set
visible
(
v
:
boolean
)
{
this
.
RoleCont
.
visible
=
v
}
_countTime
:
number
=
GameConfig
.
spCountTime
get
countTime
()
{
return
Math
.
floor
(
this
.
_countTime
/
1000
)
}
set
countTime
(
v
:
number
)
{
this
.
_countTime
=
v
this
.
CountText
.
text
=
Math
.
floor
(
v
/
1000
)
+
's'
}
didRendered
():
void
{
this
.
visible
=
false
}
cobj
=
{
t
:
3000
}
onShowCountDown
(
cb
:
Function
)
{
this
.
cobj
.
t
=
GameConfig
.
spCountTime
this
.
visible
=
true
FYGE
.
Tween
.
removeTweens
(
this
.
cobj
)
FYGE
.
Tween
.
get
(
this
.
cobj
,
{
onChange
:
()
=>
{
this
.
countTime
=
this
.
cobj
.
t
}
})
.
to
({
t
:
0
},
GameConfig
.
spCountTime
)
.
call
(()
=>
{
this
.
visible
=
false
cb
()
})
}
render
()
{
const
roleCont
=
RES
.
getRes
(
'clockBack.png'
)
return
(
<
DreamContainer
ref=
{
el
=>
{
this
.
RoleCont
=
el
}
}
inlineProps=
{
{
x
:
640
,
y
:
layers
.
stageOffsetY
+
50
}
}
>
<
DreamSprite
src=
{
roleCont
}
/>
<
DreamTextField
ref=
{
el
=>
this
.
CountText
=
el
}
text=
{
this
.
countTime
+
's'
}
color=
"#ffffff"
textWidth=
{
roleCont
.
width
+
5
}
textHeight=
{
roleCont
.
height
}
stroke=
{
2
}
size=
{
32
}
strokeColor=
"#a45549"
/>
</
DreamContainer
>
)
}
}
\ No newline at end of file
src/tools/Tools.ts
View file @
ee62695e
export
class
Tools
{
static
PageData
:
{
isFirstGame
:
boolean
,
liveCard
:
number
isFirstGame
:
boolean
}
=
{
isFirstGame
:
false
,
liveCard
:
1
isFirstGame
:
false
}
}
...
...
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