Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
崔立强
db-game-template
Commits
6c37ffa3
Commit
6c37ffa3
authored
Nov 27, 2019
by
王炽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
666666
parent
6e61e081
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
81 deletions
+67
-81
PlayScene.ts
egret/src/playScene/PlayScene.ts
+57
-2
StartScene.ts
egret/src/startScene/StartScene.ts
+10
-79
No files found.
egret/src/playScene/PlayScene.ts
View file @
6c37ffa3
...
...
@@ -50,9 +50,42 @@ export default class PlayScene extends Scene {
private
levelUpSpritePool
:
any
[]
=
[];
// 升级粒子效果
private
bg
:
LoopComponent
=
new
LoopComponent
();
private
isTest
:
boolean
;
private
closeGuideIdx
:
number
;
private
skipTimerIdx
:
number
;
async
start
(
data
?)
{
this
.
initUI
();
this
.
restart
();
this
.
isTest
=
data
;
if
(
this
.
isTest
){
this
.
eatTimes
=
159
;
this
.
currLevel
=
10
;
this
.
mainFish
.
width
=
fishesConfig
.
config
[
`lv
${
this
.
currLevel
}
`
].
uW
;
this
.
mainFish
.
height
=
fishesConfig
.
config
[
`lv
${
this
.
currLevel
}
`
].
uH
;
this
.
mainFish
.
anchorOffsetX
=
this
.
mainFish
.
width
/
2
;
this
.
mainFish
.
anchorOffsetY
=
this
.
mainFish
.
height
/
2
;
this
.
removeEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
this
.
closeGuideIdx
=
setTimeout
(()
=>
{
this
.
onclose_guide
();
this
.
onloopSkip
();
},
2000
);
}
}
private
onloopSkip
():
void
{
if
(
this
.
skipTimerIdx
)
clearTimeout
(
this
.
skipTimerIdx
);
let
tspace
=
Math
.
floor
(
Math
.
random
()
*
800
)
*
(
Math
.
random
()
>
0.4
?
1
:
-
1
);
this
.
skipTimerIdx
=
setTimeout
(()
=>
{
this
.
skip
(
12
+
Math
.
floor
(
Math
.
random
()
*
10
)
*
(
Math
.
random
()
>
0.2
?
1
:
-
1
));
this
.
onloopSkip
();
console
.
log
(
'skipTimerIdx'
);
},
(
600
+
tspace
)
<
0
?
100
:
(
600
+
tspace
));
}
initUI
()
{
...
...
@@ -142,12 +175,19 @@ export default class PlayScene extends Scene {
}
onTap_guide
()
{
if
(
!
this
.
isTest
){
this
.
onclose_guide
();
}
}
private
onclose_guide
():
void
{
this
.
guide
.
visible
=
false
;
// 初始化泡泡
this
.
initBubbles
();
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
viewport
=
0
;
onEnterFrame
()
{
/**if (this.bg1.x < -this.bg1.width) {
...
...
@@ -530,10 +570,25 @@ export default class PlayScene extends Scene {
}
onTap_stage
()
{
playSound
(
'skip_sound'
);
this
.
diveSpeed
=
-
12
;
if
(
this
.
isTest
){
if
(
this
.
closeGuideIdx
)
clearTimeout
(
this
.
closeGuideIdx
);
if
(
this
.
skipTimerIdx
)
clearTimeout
(
this
.
skipTimerIdx
);
this
.
removeEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
egret
.
Tween
.
removeAllTweens
();
setEndTime
();
sendData
();
SceneCtrl
.
instance
.
change
(
ModuleTypes
.
START_SCENE
);
}
else
{
this
.
skip
(
12
);
}
}
private
skip
(
s
:
number
):
void
{
playSound
(
'skip_sound'
);
this
.
diveSpeed
=
-
s
;
}
// 游戏结束
private
gameOver
()
{
...
...
egret/src/startScene/StartScene.ts
View file @
6c37ffa3
...
...
@@ -54,22 +54,10 @@ export default class StartScene extends Scene {
protected
initUI
()
{
playBg
();
this
.
percentWidth
=
100
;
//https://yun.duiba.com.cn/db_games/activity/video/videogame.mp4
this
.
percentHeight
=
100
;
//https://yun.duiba.com.cn/db_games/activity/gongzuozhanli/gmh/video/movie1.mp4
// if(!window['video']){
// window['video'] = new egret.Video('resource/assets/sound/videogame.mp4', true);
// window['video'].x = 0;
// window['video'].y = 0;
// window['video'].width = 1080;
// window['video'].height = 1920;
// window['video'].fullscreen = true;
// window['video'].poster = window['video'].fullscreen ? "resource/assets/startBg.jpg" : "resource/assets/startBg.jpg";
// window['video'].touchEnabled = true;
// this.addChild(window['video']);
// window['video'].addEventListener(egret.Event.COMPLETE, this.completevideo, this);
// }
// this.playVideo();
this
.
percentWidth
=
100
;
this
.
percentHeight
=
100
;
this
.
playVideo
();
}
/**
...
...
@@ -88,10 +76,6 @@ export default class StartScene extends Scene {
if
(
this
.
rankBtn
)
{
this
.
rankBtn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTap_rankBtn
,
this
);
}
// if(window['video']){
// window['video'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_video, this);
// }
}
/**
...
...
@@ -110,71 +94,17 @@ export default class StartScene extends Scene {
if
(
this
.
rankBtn
)
{
this
.
rankBtn
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTap_rankBtn
,
this
);
}
// if(window['video']){
// window['video'].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_video, this);
// }
}
// private completevideo():void{
// window['video'].removeEventListener(egret.Event.COMPLETE, this.completevideo, this);
// window['iscomplete'] = true;
// // this.playVideo();
private
playVideo
():
void
{
// console.log('555555555')
// }
if
(
this
.
videoTimeIdx
)
clearTimeout
(
this
.
videoTimeIdx
);
private
onTap_video
():
void
{
// this.playVideo();
this
.
videoTimeIdx
=
setTimeout
(()
=>
{
SceneCtrl
.
instance
.
change
(
ModuleTypes
.
PLAY_SCENE
,
true
);
},
30000
);
}
// private playVideo():void{
// if(this.videoTimeIdx) clearTimeout(this.videoTimeIdx);
// var vd = document.getElementById('my_video');
// vd.onclick = ()=>{
// vd['style'].display = 'none';
// vd['pause']();
// }
// // if(!vd.src){
// // vd['src'] = 'https://yun.duiba.com.cn/db_games/activity/gongzuozhanli/gmh/video/movie1.mp4';
// // }
// vd['style'].display = 'block';
// vd['play']();
// setTimeout(() => {
// vd['style'].display = 'none';
// vd['pause']();
// console.log('pause');
// setTimeout(() => {
// vd['style'].display = 'block';
// vd['play']();
// }, 5000);
// }, 3000);
// // var a = new egret.Video();
// // a.play()
// // this.videoTimeIdx = setTimeout(() => {
// // // if(window['iscomplete']){
// // // window['video'].play(0, true);
// // // }
// // console.log(5566666)
// // var vd:any = document.getElementById('my_video');
// // // if(!vd.src){
// // // vd['src'] = 'https://yun.duiba.com.cn/db_games/activity/gongzuozhanli/gmh/video/movie1.mp4';
// // // }
// // vd['style'].display = 'block';
// // try {
// // vd['play']();
// // } catch (error) {
// // console.log(error);
// // }
// // this.visible = false;
// // }, 3000);
// }
/**
* 点击规则按钮的事件
* @param e
...
...
@@ -203,6 +133,7 @@ export default class StartScene extends Scene {
* @param e
*/
protected
onTap_startBtn
(
e
:
egret
.
Event
)
{
if
(
this
.
videoTimeIdx
)
clearTimeout
(
this
.
videoTimeIdx
);
this
.
startBtn
.
touchEnabled
=
false
;
playSound
(
'button_sound'
);
...
...
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