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
11e1b71d
Commit
11e1b71d
authored
Mar 04, 2022
by
Master Q
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
c687a1b6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
12 deletions
+33
-12
index.html
index.html
+3
-0
ResJson.ts
src/ResJson.ts
+1
-1
Tools.ts
src/Tools.ts
+2
-1
IndexScene.ts
src/scenes/IndexScene.ts
+27
-10
No files found.
index.html
View file @
11e1b71d
...
...
@@ -70,6 +70,9 @@
var
main
=
new
Main
(
canvas
,
{
isNewGuy
:
true
});
setTimeout
(()
=>
{
GDispatcher
.
dispatchEvent
(
'GAME_START'
)
},
1000
)
var
mouseEvent
=
main
.
stage
.
onMouseEvent
.
bind
(
main
.
stage
);
canvas
.
addEventListener
(
"touchstart"
,
mouseEvent
,
false
);
canvas
.
addEventListener
(
'touchmove'
,
mouseEvent
,
false
);
...
...
src/ResJson.ts
View file @
11e1b71d
...
...
@@ -376,5 +376,5 @@ export const ResJson = {
}
}
],
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/16463
01974
/resource/"
"path"
:
"https://yun.duiba.com.cn/db_games/activity/template/16463
60490
/resource/"
}
\ No newline at end of file
src/Tools.ts
View file @
11e1b71d
...
...
@@ -39,7 +39,8 @@ export const myApp:AppType = getApp()
export
class
Tools
{
public
static
PAGE
=
{
isNewGuy
:
false
isNewGuy
:
false
,
countDownNum
:
30
};
/**
...
...
src/scenes/IndexScene.ts
View file @
11e1b71d
...
...
@@ -15,6 +15,7 @@ function randomNum(m: number, n: number) {
const
GameEvent
=
{
GAME_START
:
'GAME_START'
,
GAME_OVER
:
'GAME_OVER'
,
}
class
CountDownBoard
extends
FYGE
.
Container
{
...
...
@@ -392,16 +393,15 @@ export default class IndexScene extends Scene {
async
start
(
data
?:
any
)
{
super
.
start
()
}
/**
* 初始化倒计时器
*/
initCountDown
()
{
this
.
CountDownCont
=
this
.
addChild
(
new
CountDownBoard
(
100
))
this
.
CountDownCont
=
this
.
addChild
(
new
CountDownBoard
(
Tools
.
PAGE
.
countDownNum
))
this
.
CountDownCont
.
position
.
set
(
0
,
layers
.
stageOffsetY
+
100
)
this
.
CountDownCont
.
addEventListener
(
'countdown'
,
this
.
onGameOver
,
this
)
}
/**
...
...
@@ -494,9 +494,12 @@ export default class IndexScene extends Scene {
* 游戏开始
*/
async
onGameStart
()
{
this
.
score
=
0
if
(
Tools
.
PAGE
.
isNewGuy
)
{
await
this
.
onShowNewGuySteps
()
}
this
.
recoverGameEles
()
this
.
onInitGamer
()
await
this
.
onShowPreCountDown
()
this
.
GameStatus
=
1
this
.
CountDownCont
.
restart
()
...
...
@@ -508,22 +511,26 @@ export default class IndexScene extends Scene {
onGameOver
()
{
this
.
GameStatus
=
0
this
.
CountDownCont
.
stopCountDown
()
GDispatcher
.
dispatchEvent
(
GameEvent
.
GAME_OVER
,
{
score
:
this
.
score
})
}
/**
* 初始化游戏元素
*/
onInitGamer
()
{
this
.
RobotGameEle
=
this
.
addChild
(
new
GameEleSprit
(
'robotGamer.png'
))
if
(
!
this
.
RobotGameEle
)
{
this
.
RobotGameEle
=
this
.
addChild
(
new
GameEleSprit
(
'robotGamer.png'
))
this
.
RobotGameEle
.
addPythicCont
(
new
RectPythicCont
(
50
,
190
,
100
,
60
),
true
)
}
this
.
RobotGameEle
.
position
.
set
(
375
-
this
.
RobotGameEle
.
width
/
2
,
1100
)
this
.
RobotGameEle
.
addPythicCont
(
new
RectPythicCont
(
50
,
190
,
100
,
60
),
true
)
}
/**
* 初始化游戏掉落元素
*/
onInitFallGameEle
()
{
console
.
log
(
'onInitFallGameEle'
)
this
.
spl
=
randomNum
(
40
,
300
)
const
curr
=
this
.
currGameEleResource
const
currResource
:
GameEleResource
=
curr
.
resource
...
...
@@ -590,6 +597,15 @@ export default class IndexScene extends Scene {
this
.
RobotGameEle
.
position
.
set
(
this
.
startRobotPos
.
x
+
currPos
.
x
-
this
.
startPos
.
x
,
this
.
startRobotPos
.
y
)
}
recoverGameEles
()
{
for
(
let
i
=
0
;
i
<
this
.
gameElesList
.
length
;
i
++
)
{
const
gameEle
=
this
.
gameElesList
[
i
];
gameEle
.
visible
=
false
GPool
.
takeIn
(
gameEle
.
resource
,
gameEle
)
}
this
.
gameElesList
.
length
=
0
}
_cacheLen
:
number
=
0
frameUpdate
()
{
if
(
!
this
.
GameStatus
)
return
...
...
@@ -601,17 +617,18 @@ export default class IndexScene extends Scene {
this
.
onInitFallGameEle
()
}
this
.
gameElesList
.
forEach
((
item
)
=>
{
for
(
let
i
=
this
.
gameElesList
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
item
=
this
.
gameElesList
[
i
]
item
.
y
+=
sdt
if
(
item
.
y
>
1624
)
{
item
.
visible
=
false
GPool
.
takeIn
(
item
.
resource
,
item
)
this
.
gameElesList
.
splice
(
this
.
gameElesList
.
indexOf
(
item
)
,
1
)
this
.
gameElesList
.
splice
(
i
,
1
)
}
if
(
onCollsionJudge
(
item
.
pythicCont
.
commonPythicPos
,
this
.
RobotGameEle
.
pythicCont
.
commonPythicPos
))
{
item
.
visible
=
false
GPool
.
takeIn
(
item
.
resource
,
item
)
this
.
gameElesList
.
splice
(
this
.
gameElesList
.
indexOf
(
item
)
,
1
)
this
.
gameElesList
.
splice
(
i
,
1
)
// console.log(item)
if
(
item
.
score
==
-
1
)
{
console
.
log
(
'boom'
,
item
)
...
...
@@ -619,7 +636,7 @@ export default class IndexScene extends Scene {
}
this
.
score
+=
item
.
score
}
}
)
}
}
...
...
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