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
d2093c22
Commit
d2093c22
authored
Dec 05, 2022
by
Master Q
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
注意闭包导致的 变量引用出错
parent
4980dee1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
50 additions
and
32 deletions
+50
-32
ResJson.ts
src/ResJson.ts
+1
-1
index.tsx
src/index.tsx
+6
-1
ModalControl.tsx
src/modules/ModalControl.tsx
+9
-0
ctrls.tsx
src/modules/layers/ctrls.tsx
+2
-3
GameResumeModal.tsx
src/panels/GameResumeModal/GameResumeModal.tsx
+2
-0
GameConfig.ts
src/scenes/GameScene/GameConfig.ts
+7
-7
GameScene.tsx
src/scenes/GameScene/GameScene.tsx
+7
-4
NewGuyScene.tsx
src/scenes/NewGuyScene/NewGuyScene.tsx
+4
-4
simpleTools.ts
src/tools/simpleTools.ts
+12
-12
No files found.
src/ResJson.ts
View file @
d2093c22
...
@@ -716,5 +716,5 @@ export const ResJson = {
...
@@ -716,5 +716,5 @@ export const ResJson = {
}
}
],
],
// eslint-disable-next-line
// eslint-disable-next-line
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/16702
24643
/resource/"
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/16702
42040
/resource/"
}
}
\ No newline at end of file
src/index.tsx
View file @
d2093c22
import
{
destroyLayers
,
layers
}
from
"./modules/layers"
;
import
{
destroyLayers
,
layers
}
from
"./modules/layers"
;
import
{
SceneController
}
from
"./modules/layers/ctrls"
;
import
{
SceneController
}
from
"./modules/layers/ctrls"
;
import
{
ModalCtroller
}
from
"./modules/ModalControl"
;
import
{
RES
}
from
"./modules/RES"
;
import
{
RES
}
from
"./modules/RES"
;
import
{
ResJson
}
from
"./ResJson"
;
import
{
ResJson
}
from
"./ResJson"
;
import
{
GameScene
}
from
"./scenes/GameScene/GameScene"
;
import
{
GameScene
}
from
"./scenes/GameScene/GameScene"
;
...
@@ -20,6 +21,7 @@ import getEnv = FYGE.getEnv;
...
@@ -20,6 +21,7 @@ import getEnv = FYGE.getEnv;
export
const
GDispatcher
=
new
EventDispatcher
();
export
const
GDispatcher
=
new
EventDispatcher
();
export
const
loadAllGroups
=
async
function
()
{
export
const
loadAllGroups
=
async
function
()
{
RES
.
loadConfig
(
ResJson
)
await
RES
.
loadAllGroup
()
await
RES
.
loadAllGroup
()
}
}
...
@@ -188,7 +190,10 @@ export class Main {
...
@@ -188,7 +190,10 @@ export class Main {
this
.
stage
.
destroy
();
this
.
stage
.
destroy
();
// 全局事件置空
// 全局事件置空
// GDispatcher.removeAllEventListener();
GDispatcher
.
removeAllEventListener
();
// 晴空下
ModalCtroller
.
clearModalMap
()
// 淘宝环境网络数据记录清
// 淘宝环境网络数据记录清
// destroyTbNetData();
// destroyTbNetData();
...
...
src/modules/ModalControl.tsx
View file @
d2093c22
...
@@ -190,9 +190,18 @@ export const ModalCtroller = (function() {
...
@@ -190,9 +190,18 @@ export const ModalCtroller = (function() {
(
_
.
ModalContainer
as
FYGE
.
Container
).
destroy
();
(
_
.
ModalContainer
as
FYGE
.
Container
).
destroy
();
ModalMap
.
delete
(
ModalNode
)
ModalMap
.
delete
(
ModalNode
)
}
}
console
.
log
(
'closeModal config:'
,
_
.
props
.
_config
,
ModalMap
)
return
return
}
}
},
closeAllModal
()
{
ModalMap
.
forEach
(
item
=>
{
item
.
closeModal
&&
item
.
closeModal
()
})
},
clearModalMap
()
{
ModalMap
.
clear
()
}
}
}
}
})()
})()
\ No newline at end of file
src/modules/layers/ctrls.tsx
View file @
d2093c22
...
@@ -74,14 +74,13 @@ export const SceneController = (function() {
...
@@ -74,14 +74,13 @@ export const SceneController = (function() {
let
preScene
:
SceneCompent
// 之前一个场景的
let
preScene
:
SceneCompent
// 之前一个场景的
return
{
return
{
init
(
cont
:
FYGE
.
Container
)
{
init
(
cont
:
FYGE
.
Container
)
{
if
(
!
controller
)
{
controller
=
cont
controller
=
cont
}
},
},
destroyScene
(
scene
:
SceneCompent
)
{
destroyScene
(
scene
:
SceneCompent
)
{
scene
.
destroy
()
scene
.
destroy
()
},
},
changeScene
(
SceneNode
:
any
,
props
?:
Record
<
string
,
any
>
)
{
changeScene
(
SceneNode
:
any
,
props
?:
Record
<
string
,
any
>
)
{
console
.
log
(
'controller==='
,
controller
)
if
(
!
controller
)
{
if
(
!
controller
)
{
throw
new
Error
(
'没有场景controller'
)
throw
new
Error
(
'没有场景controller'
)
}
}
...
...
src/panels/GameResumeModal/GameResumeModal.tsx
View file @
d2093c22
...
@@ -50,6 +50,8 @@ export class GameResumeModal extends Dream.RenderContainer<{
...
@@ -50,6 +50,8 @@ export class GameResumeModal extends Dream.RenderContainer<{
* 确认走复活逻辑
* 确认走复活逻辑
*/
*/
onConfirm
=
async
()
=>
{
onConfirm
=
async
()
=>
{
clearInterval
(
this
.
intervalId
)
const
{
const
{
success
success
}
=
await
sendTbNet
(
TbNetName
.
reduceTools
)
}
=
await
sendTbNet
(
TbNetName
.
reduceTools
)
...
...
src/scenes/GameScene/GameConfig.ts
View file @
d2093c22
...
@@ -47,7 +47,7 @@ export const GameConfig = {
...
@@ -47,7 +47,7 @@ export const GameConfig = {
boxConfig
:
{
boxConfig
:
{
[
BoxType
.
Box1
]:
{
[
BoxType
.
Box1
]:
{
resName
:
'box1.png'
,
resName
:
'box1.png'
,
addScore
:
5
,
addScore
:
4
,
oc
:
{
oc
:
{
x
:
142
,
y
:
230
// 判断中心点
x
:
142
,
y
:
230
// 判断中心点
},
},
...
@@ -67,7 +67,7 @@ export const GameConfig = {
...
@@ -67,7 +67,7 @@ export const GameConfig = {
},
},
[
BoxType
.
Box3
]:
{
[
BoxType
.
Box3
]:
{
resName
:
'box3.png'
,
resName
:
'box3.png'
,
addScore
:
5
,
addScore
:
6
,
oc
:
{
oc
:
{
x
:
142
,
y
:
230
x
:
142
,
y
:
230
},
},
...
@@ -77,7 +77,7 @@ export const GameConfig = {
...
@@ -77,7 +77,7 @@ export const GameConfig = {
},
},
[
BoxType
.
Box4
]:
{
[
BoxType
.
Box4
]:
{
resName
:
'box4.png'
,
resName
:
'box4.png'
,
addScore
:
5
,
addScore
:
8
,
oc
:
{
oc
:
{
x
:
142
,
y
:
250
x
:
142
,
y
:
250
},
},
...
@@ -87,7 +87,7 @@ export const GameConfig = {
...
@@ -87,7 +87,7 @@ export const GameConfig = {
},
},
[
BoxType
.
Box5
]:
{
[
BoxType
.
Box5
]:
{
resName
:
'box5.png'
,
resName
:
'box5.png'
,
addScore
:
5
,
addScore
:
10
,
oc
:
{
oc
:
{
x
:
142
,
y
:
260
x
:
142
,
y
:
260
},
},
...
@@ -97,7 +97,7 @@ export const GameConfig = {
...
@@ -97,7 +97,7 @@ export const GameConfig = {
},
},
[
BoxType
.
Box6
]:
{
[
BoxType
.
Box6
]:
{
resName
:
'box6.png'
,
resName
:
'box6.png'
,
addScore
:
5
,
addScore
:
1
,
oc
:
{
oc
:
{
x
:
142
,
y
:
230
x
:
142
,
y
:
230
},
},
...
@@ -107,7 +107,7 @@ export const GameConfig = {
...
@@ -107,7 +107,7 @@ export const GameConfig = {
},
},
[
BoxType
.
Box7
]:
{
[
BoxType
.
Box7
]:
{
resName
:
'box7.png'
,
resName
:
'box7.png'
,
addScore
:
5
,
addScore
:
1
5
,
oc
:
{
oc
:
{
x
:
142
,
y
:
360
x
:
142
,
y
:
360
},
},
...
@@ -117,7 +117,7 @@ export const GameConfig = {
...
@@ -117,7 +117,7 @@ export const GameConfig = {
},
},
[
BoxType
.
Box8
]:
{
[
BoxType
.
Box8
]:
{
resName
:
'box8.png'
,
resName
:
'box8.png'
,
addScore
:
5
,
addScore
:
1
5
,
oc
:
{
oc
:
{
x
:
142
,
y
:
360
x
:
142
,
y
:
360
},
},
...
...
src/scenes/GameScene/GameScene.tsx
View file @
d2093c22
...
@@ -258,7 +258,7 @@ export class GameScene extends Dream.RenderContainer {
...
@@ -258,7 +258,7 @@ export class GameScene extends Dream.RenderContainer {
offsetY
:
py
,
offsetY
:
py
,
maxH
:
mh
maxH
:
mh
})
})
console
.
log
(
'jumpEnd
'
)
console
.
log
(
'jumpEnd
:'
,
_i
)
if
(
_i
==
3
)
{
if
(
_i
==
3
)
{
this
.
onJumpSuc
()
this
.
onJumpSuc
()
}
else
if
(
_i
==
2
||
_i
==
-
1
)
{
}
else
if
(
_i
==
2
||
_i
==
-
1
)
{
...
@@ -267,6 +267,7 @@ export class GameScene extends Dream.RenderContainer {
...
@@ -267,6 +267,7 @@ export class GameScene extends Dream.RenderContainer {
}
}
onJumpSuc
()
{
onJumpSuc
()
{
console
.
log
(
'onJumpSuc'
)
if
(
this
.
isWithGift
)
{
if
(
this
.
isWithGift
)
{
this
.
DecisionConfig
.
geleIns
.
onGetGift
()
this
.
DecisionConfig
.
geleIns
.
onGetGift
()
this
.
isDrawed
=
true
this
.
isDrawed
=
true
...
@@ -281,6 +282,7 @@ export class GameScene extends Dream.RenderContainer {
...
@@ -281,6 +282,7 @@ export class GameScene extends Dream.RenderContainer {
onGameOver
()
{
onGameOver
()
{
this
.
isOver
=
true
this
.
isOver
=
true
let
f
=
Tools
.
PageData
.
liveCard
let
f
=
Tools
.
PageData
.
liveCard
console
.
log
(
'GameOver'
)
if
(
f
&&
!
this
.
isUsed
)
{
if
(
f
&&
!
this
.
isUsed
)
{
ModalCtroller
.
showModal
(
GameResumeModal
,
{
ModalCtroller
.
showModal
(
GameResumeModal
,
{
resumeNum
:
Tools
.
PageData
.
liveCard
,
resumeNum
:
Tools
.
PageData
.
liveCard
,
...
@@ -335,6 +337,9 @@ export class GameScene extends Dream.RenderContainer {
...
@@ -335,6 +337,9 @@ export class GameScene extends Dream.RenderContainer {
}
}
onShowGameOverModal
=
async
()
=>
{
onShowGameOverModal
=
async
()
=>
{
if
(
this
.
isDrawed
)
{
await
this
.
onDraw
()
}
const
submitScore
=
this
.
ScoreBoardIns
.
score
const
submitScore
=
this
.
ScoreBoardIns
.
score
const
{
const
{
success
success
...
@@ -342,9 +347,6 @@ export class GameScene extends Dream.RenderContainer {
...
@@ -342,9 +347,6 @@ export class GameScene extends Dream.RenderContainer {
score
:
submitScore
score
:
submitScore
})
})
if
(
success
)
{
if
(
success
)
{
if
(
this
.
isDrawed
)
{
await
this
.
onDraw
()
}
ModalCtroller
.
showModal
(
GameOverModal
,
{
ModalCtroller
.
showModal
(
GameOverModal
,
{
...
@@ -591,6 +593,7 @@ export class GameScene extends Dream.RenderContainer {
...
@@ -591,6 +593,7 @@ export class GameScene extends Dream.RenderContainer {
render
()
{
render
()
{
const
bottomAtomRes
=
RES
.
getRes
(
'bottomAtom.png'
)
const
bottomAtomRes
=
RES
.
getRes
(
'bottomAtom.png'
)
console
.
log
(
'render GameScene'
)
return
(
return
(
<
FYGE
.
Container
>
<
FYGE
.
Container
>
...
...
src/scenes/NewGuyScene/NewGuyScene.tsx
View file @
d2093c22
...
@@ -47,7 +47,7 @@ export class NewGuyScene extends Dream.RenderContainer {
...
@@ -47,7 +47,7 @@ export class NewGuyScene extends Dream.RenderContainer {
}
}
const
mapName
=
Object
.
keys
(
posMap
)
const
mapName
=
Object
.
keys
(
posMap
)
this
.
GuideContainer
.
addChild
(
this
.
GuideContainer
.
addChild
(
<
DreamContainer
>
<
DreamContainer
onClick=
{
nextStep
}
>
<
DreamShape
alpha=
{
0.7
}
/>
<
DreamShape
alpha=
{
0.7
}
/>
<
DreamContainer
inlineProps=
{
{
<
DreamContainer
inlineProps=
{
{
...
@@ -78,7 +78,7 @@ export class NewGuyScene extends Dream.RenderContainer {
...
@@ -78,7 +78,7 @@ export class NewGuyScene extends Dream.RenderContainer {
y
:
1100
y
:
1100
}
}
text=
"踩到特殊格子 可获得额外得分"
color=
"#ffffff"
textWidth=
{
750
}
size=
{
32
}
/>
}
}
text=
"踩到特殊格子 可获得额外得分"
color=
"#ffffff"
textWidth=
{
750
}
size=
{
32
}
/>
<
DreamSprite
onClick=
{
nextStep
}
inlineProps=
{
{
<
DreamSprite
inlineProps=
{
{
x
:
375
-
n
.
width
/
2
,
x
:
375
-
n
.
width
/
2
,
y
:
1200
y
:
1200
}
}
src=
{
n
}
/>
}
}
src=
{
n
}
/>
...
@@ -88,7 +88,7 @@ export class NewGuyScene extends Dream.RenderContainer {
...
@@ -88,7 +88,7 @@ export class NewGuyScene extends Dream.RenderContainer {
case
3
:
case
3
:
const
btn
=
RES
.
getRes
(
'startGameBtn.png'
)
const
btn
=
RES
.
getRes
(
'startGameBtn.png'
)
this
.
GuideContainer
.
addChild
(
this
.
GuideContainer
.
addChild
(
<
DreamContainer
>
<
DreamContainer
onClick=
{
nextStep
}
>
<
DreamShape
alpha=
{
0.7
}
/>
<
DreamShape
alpha=
{
0.7
}
/>
<
DreamTextField
text=
"踩到特殊道具"
color=
"#ffffff"
size=
{
fontSize
}
textWidth=
{
750
}
inlineProps=
{
{
<
DreamTextField
text=
"踩到特殊道具"
color=
"#ffffff"
size=
{
fontSize
}
textWidth=
{
750
}
inlineProps=
{
{
...
@@ -98,7 +98,7 @@ export class NewGuyScene extends Dream.RenderContainer {
...
@@ -98,7 +98,7 @@ export class NewGuyScene extends Dream.RenderContainer {
y
:
770
y
:
770
}
}
/>
}
}
/>
<
DreamSprite
src=
{
btn
}
onClick=
{
nextStep
}
inlineProps=
{
{
<
DreamSprite
src=
{
btn
}
inlineProps=
{
{
x
:
375
-
btn
.
width
/
2
,
x
:
375
-
btn
.
width
/
2
,
y
:
850
y
:
850
}
}
/>
}
}
/>
...
...
src/tools/simpleTools.ts
View file @
d2093c22
// @ts-ignore
const
app
=
typeof
getApp
==
'function'
&&
getApp
()
const
audioIns
=
app
?.
audioContext
if
(
audioIns
)
{
audioIns
.
onPlay
(()
=>
{
console
.
log
(
'播放'
)
})
audioIns
.
onError
(()
=>
{
console
.
log
(
'audio error'
)
})
}
export
function
PlayAudio
()
{
export
function
PlayAudio
()
{
console
.
log
(
'app ====='
,
app
)
// @ts-ignore
const
app
=
typeof
getApp
==
'function'
&&
getApp
()
const
audioIns
=
app
?.
audioContext
if
(
audioIns
)
{
audioIns
.
onPlay
(()
=>
{
console
.
log
(
'播放'
)
})
audioIns
.
onError
(()
=>
{
console
.
log
(
'audio error'
)
})
}
audioIns
&&
audioIns
.
play
()
audioIns
&&
audioIns
.
play
()
}
}
...
...
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