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
spc
JsxForFYGETemplate
Commits
3bd5ba7f
Commit
3bd5ba7f
authored
Mar 03, 2023
by
Master Q
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Go
parent
d299bf9a
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
293 additions
and
33 deletions
+293
-33
index.html
index.html
+58
-2
Guide5.png
resource/NewGuyScene/Guide5.png
+0
-0
res.json
resource/res.json
+1
-1
ResJson.ts
src/ResJson.ts
+13
-2
index.tsx
src/index.tsx
+5
-0
GameConfig.ts
src/scenes/GameScene/GameConfig.ts
+42
-4
GameScene.tsx
src/scenes/GameScene/GameScene.tsx
+41
-16
Guidance.ts
src/scenes/GameScene/Guidance.ts
+42
-0
IntersectionObserver.ts
src/scenes/GameScene/IntersectionObserver.ts
+65
-0
SpClock.tsx
src/scenes/GameScene/SpClock.tsx
+3
-3
NewGuyScene.tsx
src/scenes/NewGuyScene/NewGuyScene.tsx
+8
-3
Tools.ts
src/tools/Tools.ts
+15
-2
No files found.
index.html
View file @
3bd5ba7f
...
...
@@ -70,8 +70,64 @@
canvas
.
width
=
document
.
body
.
clientWidth
*
(
window
.
devicePixelRatio
||
1
)
canvas
.
height
=
document
.
body
.
clientHeight
*
(
window
.
devicePixelRatio
||
1
)
new
Main
(
canvas
,
{
isFirstGame
:
false
,
skinName
:
'c'
isFirstGame
:
true
,
skinName
:
'c'
,
gameDiff
:
[],
extraFunc
:
(
function
(
lc
,
et
,
es
)
{
let
lifeCount
=
lc
let
timer
let
tweenSelf1
let
tweenSelf2
function
reset
()
{
for
(
let
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
arguments
[
i
].
alpha
=
1
}
}
return
function
(
type
)
{
// 炸弹
let
cb
=
()
=>
{}
if
(
type
==
3
)
{
--
lifeCount
if
(
lifeCount
>
0
)
{
cb
=
function
(
r
,
c
)
{
clearTimeout
(
timer
)
reset
(
r
,
c
)
FYGE
.
Tween
.
removeTweenSelf
(
tweenSelf1
)
FYGE
.
Tween
.
removeTweenSelf
(
tweenSelf2
)
tweenSelf1
=
FYGE
.
Tween
.
get
(
r
,
{
loop
:
true
}).
to
({
alpha
:
0.5
},
300
).
to
({
alpha
:
1
},
300
)
tweenSelf2
=
FYGE
.
Tween
.
get
(
c
,
{
loop
:
true
}).
to
({
alpha
:
0.5
},
300
).
to
({
alpha
:
1
},
300
)
timer
=
setTimeout
(()
=>
{
reset
(
r
,
c
)
FYGE
.
Tween
.
removeTweenSelf
(
tweenSelf1
)
FYGE
.
Tween
.
removeTweenSelf
(
tweenSelf2
)
},
2000
)
}
}
}
return
{
extraScore
:
es
,
done
:
lifeCount
==
0
,
extraTime
:
et
,
landCb
:
cb
}
}
})(
2
,
2000
,
20
)
})
})
...
...
resource/NewGuyScene/Guide5.png
0 → 100644
View file @
3bd5ba7f
983 KB
resource/res.json
View file @
3bd5ba7f
...
...
@@ -5,7 +5,7 @@
"name"
:
"GameScene"
},
{
"keys"
:
"Guide1.png,Guide2.png,Guide3.png,Guide4.png"
,
"keys"
:
"Guide1.png,Guide2.png,Guide3.png,Guide4.png
,Guide5.png
"
,
"name"
:
"NewGuyScene"
},
{
...
...
src/ResJson.ts
View file @
3bd5ba7f
...
...
@@ -84,7 +84,7 @@ export const ResJson = {
}
},
{
"keys"
:
"Guide1.png,Guide2.png,Guide3.png,Guide4.png"
,
"keys"
:
"Guide1.png,Guide2.png,Guide3.png,Guide4.png
,Guide5.png
"
,
"name"
:
"NewGuyScene"
,
"atlas"
:
{
"Guide1.png"
:
{
...
...
@@ -130,6 +130,17 @@ export const ResJson = {
"sw"
:
750
,
"sh"
:
1624
,
"ro"
:
true
},
"Guide5.png"
:
{
"x"
:
2258
,
"y"
:
2
,
"w"
:
750
,
"h"
:
1624
,
"ox"
:
0
,
"oy"
:
0
,
"sw"
:
750
,
"sh"
:
1624
,
"ro"
:
false
}
}
},
...
...
@@ -193,5 +204,5 @@ export const ResJson = {
}
],
// eslint-disable-next-line
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/167
1522711
/resource/"
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/167
7835925
/resource/"
}
\ No newline at end of file
src/index.tsx
View file @
3bd5ba7f
...
...
@@ -39,6 +39,11 @@ export class Main {
canvas
:
HTMLCanvasElement
,
config
:
{
isFirstGame
:
boolean
skinName
:
string
,
gameDiff
:
{
score
:
number
speed
:
number
}[]
},
desWidth
=
750
,
desHeight
=
1624
,
...
...
src/scenes/GameScene/GameConfig.ts
View file @
3bd5ba7f
...
...
@@ -19,12 +19,50 @@ export const GameConfig = {
},
DecisionLine
:
[
// 判定线 当前屏幕显示区域
3
00
,
8
00
,
layers
.
stageHeight
,
// 这里个需要后续设定
],
landPlatformScore
:
2
,
// 平台上的分数
spCountTime
:
3100
,
//道具倒计时
boxColNum
:
5
,
// 几列格子
sptMap
:
{
initPos
:
{
x
:
1
,
y
:
26
,
},
boxMap
:
[
[
0
,
0
,
1
,
0
,
0
],
[
0
,
0
,
1
,
2
,
0
],
[
0
,
0
,
1
,
1
,
0
],
[
0
,
1
,
0
,
0
,
1
],
[
0
,
0
,
1
,
1
,
0
],
[
0
,
0
,
0
,
1
,
1
],
[
0
,
0
,
1
,
1
,
0
],
[
0
,
2
,
1
,
0
,
0
],
[
1
,
0
,
0
,
1
,
0
],
[
0
,
0
,
1
,
0
,
1
],
[
0
,
1
,
0
,
1
,
0
],
[
1
,
0
,
1
,
0
,
0
],
[
0
,
1
,
0
,
0
,
1
],
[
1
,
0
,
0
,
1
,
0
],
[
0
,
1
,
2
,
0
,
0
],
[
0
,
1
,
1
,
0
,
0
],
[
1
,
0
,
0
,
1
,
0
],
[
0
,
2
,
0
,
0
,
1
],
[
1
,
0
,
1
,
0
,
0
],
[
1
,
1
,
0
,
1
,
0
],
[
0
,
0
,
1
,
0
,
0
],
[
1
,
1
,
0
,
1
,
0
],
[
0
,
0
,
1
,
0
,
1
],
[
1
,
0
,
0
,
6
,
1
],
[
0
,
1
,
0
,
1
,
0
],
[
0
,
1
,
1
,
,
0
],
[
1
,
1
,
0
,
0
,
0
],
[
0
,
0
,
1
,
0
,
1
],
[
0
,
1
,
0
,
2
,
0
],
[
0
,
0
,
1
,
0
,
0
],
],
},
mapList
:
[
{
initPos
:
{
...
...
@@ -61,7 +99,7 @@ export const GameConfig = {
[
0
,
3
,
1
,
0
,
4
],
[
4
,
0
,
0
,
5
,
0
],
[
0
,
4
,
2
,
0
,
1
],
[
1
,
1
,
5
,
2
,
1
],
[
1
,
1
,
1
,
1
,
1
],
],
},
{
...
...
@@ -99,7 +137,7 @@ export const GameConfig = {
[
1
,
0
,
1
,
0
,
0
],
[
0
,
0
,
1
,
0
,
4
],
[
4
,
0
,
0
,
4
,
0
],
[
0
,
1
,
4
,
1
,
0
],
[
0
,
1
,
1
,
1
,
0
],
],
},
{
...
...
@@ -137,7 +175,7 @@ export const GameConfig = {
[
0
,
0
,
1
,
0
,
5
],
[
1
,
4
,
0
,
0
,
0
],
[
0
,
0
,
0
,
4
,
1
],
[
1
,
5
,
1
,
0
,
4
],
[
1
,
1
,
1
,
0
,
1
],
],
},
{
...
...
src/scenes/GameScene/GameScene.tsx
View file @
3bd5ba7f
...
...
@@ -6,7 +6,7 @@ import Dream from "../../Dream";
import
{
layers
}
from
"../../modules/layers"
;
import
{
RES
}
from
"../../modules/RES"
;
import
{
UsePreload
}
from
"../../modules/UseDecorator/usePreload"
;
import
{
PromiseAwait
,
PromiseAwaitCacheMap
}
from
"../../tools/Tools"
;
import
{
PromiseAwait
,
PromiseAwaitCacheMap
,
Tools
}
from
"../../tools/Tools"
;
import
{
GameConfig
}
from
"./GameConfig"
;
import
{
G_Events
}
from
"./GameEvents"
;
import
{
Platform
}
from
"./Platform"
;
...
...
@@ -62,13 +62,15 @@ export class GameScene extends Dream.RenderContainer {
rabbitIns
:
PlayerIns
cloneRabbitIns
:
PlayerIns
GuidanceCont
:
FYGE
.
Container
set
dir
(
v
:
number
)
{
this
.
rabbitContainer
.
scaleX
=
v
this
.
rabbitCloneContainer
.
scaleX
=
v
}
didRendered
():
void
{
this
.
renderMap
(
true
)
this
.
renderMap
(
true
,
GameConfig
.
sptMap
)
this
.
initEvents
()
...
...
@@ -77,7 +79,6 @@ export class GameScene extends Dream.RenderContainer {
unMount
():
void
{
this
.
removeEvents
()
PromiseAwaitCacheMap
.
clear
()
}
...
...
@@ -124,6 +125,7 @@ export class GameScene extends Dream.RenderContainer {
this
.
onShowRabbitAni
(
RabbitActionMap
.
Fail
)
FYGE
.
Tween
.
removeTweens
(
this
.
rabbitContainer
)
FYGE
.
Tween
.
removeTweens
(
this
.
rabbitCloneContainer
)
this
.
isPause
=
true
GDispatcher
.
dispatchEvent
(
G_Events
.
GameOver
,
this
.
ScoreBoardIns
.
score
)
...
...
@@ -141,10 +143,13 @@ export class GameScene extends Dream.RenderContainer {
* 开始渲染地图
* @param init 是否是初始化
*/
renderMap
(
init
:
boolean
=
false
)
{
renderMap
(
init
:
boolean
=
false
,
mapConfig
?:
any
)
{
if
(
!
mapConfig
)
{
const
index
=
Math
.
random
()
*
GameConfig
.
mapList
.
length
>>
0
console
.
info
(
'=========render map ===========:'
,
index
)
const
mapConfig
=
GameConfig
.
mapList
[
index
]
mapConfig
=
GameConfig
.
mapList
[
index
]
}
const
{
rowNum
,
offsetYLen
...
...
@@ -201,10 +206,10 @@ export class GameScene extends Dream.RenderContainer {
if
(
colItem
)
{
return
<
Platform
ref=
{
el
=>
{
return
<
Platform
ref=
{
(
el
:
Platform
)
=>
{
rowArr
[
colIndex
]
=
el
}
}
pos=
{
[
rowIndex
,
colIndex
]
}
type=
{
colItem
}
x=
{
colIndex
*
offsetXLen
}
/>
pos=
{
[
rowIndex
,
colIndex
]
}
type=
{
colItem
%
4
}
x=
{
colIndex
*
offsetXLen
}
/>
}
else
{
rowArr
[
colIndex
]
=
undefined
return
undefined
...
...
@@ -219,8 +224,6 @@ export class GameScene extends Dream.RenderContainer {
,
0
)
this
.
mapCount
+=
1
// 增加速度
GameConfig
.
speed
+=
GameConfig
.
mapChangeAddSpeed
this
.
rabbitBoxMap
.
unshift
(...
mapPlatform
)
// 第三章图片的话,清楚掉第一张地图
...
...
@@ -327,7 +330,7 @@ export class GameScene extends Dream.RenderContainer {
const
afterCb
=
this
.
onPlatformLand
(
landPlatform
)
FYGE
.
Tween
.
removeTweens
(
rabbitContainer
)
//
FYGE.Tween.removeTweens(rabbitContainer)
if
(
rax
==
4
)
{
rabbitCloneContainer
.
visible
=
true
rabbitCloneContainer
.
position
.
set
(
rabbitContainer
.
x
-
750
,
rabbitContainer
.
y
)
...
...
@@ -381,8 +384,19 @@ export class GameScene extends Dream.RenderContainer {
let
noop
=
()
=>
{}
platform
.
onLand
((
type
:
number
,
s
:
number
,
cb
:
Function
)
=>
{
const
extraConfig
=
Tools
.
PageData
.
extraFunc
?
Tools
.
PageData
.
extraFunc
(
type
)
:
{
extraScore
:
0
,
done
:
false
,
extraTime
:
0
,
landCb
:
()
=>
{}
}
const
isDone
=
type
==
3
&&
extraConfig
.
done
// pre 去做动作吧
if
(
type
==
3
)
{
if
(
isDone
)
{
this
.
onShowRabbitAni
(
RabbitActionMap
.
Jump
,
RabbitActionMap
.
Fail
)
}
else
if
(
type
==
2
)
{
this
.
onShowRabbitAni
(
RabbitActionMap
.
Jump
,
RabbitActionMap
.
Smile
)
...
...
@@ -393,15 +407,16 @@ export class GameScene extends Dream.RenderContainer {
// 落地的回调
noop
=
()
=>
{
cb
()
if
(
type
==
3
)
{
extraConfig
.
landCb
(
this
.
rabbitContainer
,
this
.
rabbitCloneContainer
)
if
(
isDone
)
{
return
this
.
onGameOver
()
}
else
if
(
type
==
2
)
{
this
.
double
=
2
this
.
SpClockIns
.
onShowCountDown
(()
=>
{
this
.
double
=
1
})
}
,
extraConfig
.
extraTime
)
}
this
.
onAddScore
(
s
)
this
.
onAddScore
(
s
+
extraConfig
.
extraScore
||
0
)
}
})
...
...
@@ -414,6 +429,12 @@ export class GameScene extends Dream.RenderContainer {
*/
onAddScore
(
s
:
number
)
{
this
.
ScoreBoardIns
.
score
+=
s
*
this
.
double
const
currScore
=
this
.
ScoreBoardIns
.
score
const
speedScoreMap
=
Tools
.
PageData
.
gameDiff
const
currConfig
=
speedScoreMap
.
find
(
it
=>
currScore
<
it
.
score
)
||
{
speed
:
200
}
GameConfig
.
speed
=
currConfig
.
speed
console
.
info
(
'游戏速度:'
,
GameConfig
.
speed
,
currConfig
)
}
GameJudgeFrame
()
{
...
...
@@ -446,6 +467,10 @@ export class GameScene extends Dream.RenderContainer {
<
ScoreBoard
ref=
{
(
el
:
ScoreBoard
)
=>
this
.
ScoreBoardIns
=
el
}
/>
<
SpClock
ref=
{
(
el
:
SpClock
)
=>
this
.
SpClockIns
=
el
}
/>
<
DreamContainer
ref=
{
el
=>
{
this
.
GuidanceCont
=
el
}
}
></
DreamContainer
>
</
DreamContainer
>
)
}
...
...
src/scenes/GameScene/Guidance.ts
0 → 100644
View file @
3bd5ba7f
export
class
Guidance
{
parent
:
FYGE
.
Container
currStep
:
number
pause
:
()
=>
void
play
:
()
=>
void
constructor
(
parent
:
FYGE
.
Container
,
currStep
:
number
,
pause
:
()
=>
void
,
play
:
()
=>
void
)
{
this
.
parent
=
parent
this
.
currStep
=
currStep
this
.
pause
=
pause
this
.
play
=
play
}
showGuide
(
pos
:
any
,
s
:
number
)
{
const
{
currStep
,
parent
}
=
this
if
(
!
(
s
>
currStep
))
{
return
}
this
.
currStep
++
this
.
pause
()
parent
.
removeAllChildren
()
const
shape
=
new
FYGE
.
Graphics
()
shape
.
beginFill
(
'#000000'
,
0.7
)
.
drawRect
(
0
,
0
,
750
,
1624
)
.
endFill
()
.
beginHole
()
.
arc
(
pos
.
x
,
pos
.
y
,
150
,
0
,
2
*
Math
.
PI
)
.
endHole
()
parent
.
addChild
(
shape
)
switch
(
currStep
)
{
case
1
:
break
}
}
}
\ No newline at end of file
src/scenes/GameScene/IntersectionObserver.ts
0 → 100644
View file @
3bd5ba7f
import
{
layers
}
from
"../../modules/layers"
type
CallArgs
<
T
extends
any
>
=
{
isIntersecting
:
boolean
,
target
:
T
,
pos
:
FYGE
.
Point
}
type
EventCall
<
T
extends
any
>
=
(
e
?:
CallArgs
<
T
>
)
=>
any
type
OffsetPos
=
{
x
:
number
,
y
:
number
}
export
class
IntersectionObserver
<
TE
extends
FYGE
.
Container
>
{
private
obCallBack
?:
(
changes
:
CallArgs
<
TE
>
[])
=>
void
entries
:
{
t
:
TE
,
offset
:
OffsetPos
cb
:
EventCall
<
TE
>
}[]
=
[]
constructor
(
obCallBack
?:
(
changes
:
CallArgs
<
TE
>
[])
=>
void
)
{
this
.
entries
=
[]
this
.
obCallBack
=
obCallBack
}
flush
()
{
const
_copy
=
this
.
entries
.
slice
(
0
)
const
tempPoint
=
new
FYGE
.
Point
()
const
result
=
[]
for
(
let
i
=
_copy
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
currItem
=
_copy
[
i
]
tempPoint
.
set
(
currItem
.
offset
.
x
,
currItem
.
offset
.
y
)
const
p
=
currItem
.
t
.
localToGlobal
(
tempPoint
)
if
(
p
.
x
>=
0
&&
p
.
y
>=
layers
.
stageOffsetY
&&
p
.
x
<=
layers
.
stageWidth
&&
p
.
y
<=
layers
.
stageOffsetY
+
layers
.
stageHeight
)
{
const
arg
=
{
target
:
currItem
.
t
,
isIntersecting
:
true
,
pos
:
p
}
currItem
.
cb
(
arg
)
result
.
push
(
arg
)
}
}
this
.
obCallBack
&&
this
.
obCallBack
(
result
)
}
observe
<
T
extends
TE
>
(
target
:
T
,
offset
:
OffsetPos
=
{
x
:
0
,
y
:
0
},
cb
?:
EventCall
<
T
>
)
{
this
.
entries
.
push
({
t
:
target
,
offset
,
cb
})
}
unobserve
<
T
extends
TE
>
(
target
:
T
)
{
const
i
=
this
.
entries
.
findIndex
(
c
=>
c
.
t
==
target
)
i
!==
-
1
&&
this
.
entries
.
splice
(
i
,
1
)
}
unobserveAll
()
{
this
.
entries
.
length
=
0
}
}
src/scenes/GameScene/SpClock.tsx
View file @
3bd5ba7f
...
...
@@ -26,8 +26,8 @@ export class SpClock extends Dream.RenderContainer {
}
cobj
=
{
t
:
3000
}
onShowCountDown
(
cb
:
Function
)
{
this
.
cobj
.
t
=
GameConfig
.
spCountTime
onShowCountDown
(
cb
:
Function
,
exT
:
number
)
{
this
.
cobj
.
t
=
GameConfig
.
spCountTime
+
exT
this
.
visible
=
true
FYGE
.
Tween
.
removeTweens
(
this
.
cobj
)
FYGE
.
Tween
.
get
(
this
.
cobj
,
{
...
...
@@ -37,7 +37,7 @@ export class SpClock extends Dream.RenderContainer {
})
.
to
({
t
:
0
},
GameConfig
.
spCountTime
)
},
GameConfig
.
spCountTime
+
exT
)
.
call
(()
=>
{
this
.
visible
=
false
cb
()
...
...
src/scenes/NewGuyScene/NewGuyScene.tsx
View file @
3bd5ba7f
...
...
@@ -32,20 +32,25 @@ export class NewGuyScene extends Dream.RenderContainer {
break
case
2
:
this
.
GuideContainer
.
addChild
(<
DreamContainer
onClick=
{
nextStep
}
>
<
DreamSprite
src=
{
RES
.
getRes
(
'Guide
2
.png'
)
}
/>
<
DreamSprite
src=
{
RES
.
getRes
(
'Guide
5
.png'
)
}
/>
</
DreamContainer
>)
break
case
3
:
this
.
GuideContainer
.
addChild
(<
DreamContainer
onClick=
{
nextStep
}
>
<
DreamSprite
src=
{
RES
.
getRes
(
'Guide
3
.png'
)
}
/>
<
DreamSprite
src=
{
RES
.
getRes
(
'Guide
2
.png'
)
}
/>
</
DreamContainer
>)
break
case
4
:
this
.
GuideContainer
.
addChild
(<
DreamContainer
onClick=
{
nextStep
}
>
<
DreamSprite
src=
{
RES
.
getRes
(
'Guide
4
.png'
)
}
/>
<
DreamSprite
src=
{
RES
.
getRes
(
'Guide
3
.png'
)
}
/>
</
DreamContainer
>)
break
case
5
:
this
.
GuideContainer
.
addChild
(<
DreamContainer
onClick=
{
nextStep
}
>
<
DreamSprite
src=
{
RES
.
getRes
(
'Guide4.png'
)
}
/>
</
DreamContainer
>)
break
case
6
:
// 完成新手引导
SceneController
.
changeScene
(
GameScene
)
break
...
...
src/tools/Tools.ts
View file @
3bd5ba7f
type
ExtraConfig
=
{
extraScore
:
number
,
done
:
boolean
extraTime
:
number
,
landCb
:
(...
args
:
any
[])
=>
void
}
export
class
Tools
{
static
PageData
:
{
isFirstGame
:
boolean
skinName
:
string
skinName
:
string
,
gameDiff
:
{
score
:
number
speed
:
number
}[],
extraFunc
?:
(...
args
:
any
[])
=>
ExtraConfig
}
=
{
isFirstGame
:
false
,
skinName
:
''
skinName
:
''
,
gameDiff
:
[]
}
}
...
...
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