Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crazyflirt
Project
Overview
Details
Activity
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
Shawn Wang
crazyflirt
Commits
480f2513
Commit
480f2513
authored
May 06, 2018
by
Mike Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建gameover页面
parent
28c14e0c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
3 deletions
+126
-3
Main.ts
fe/src/Main.ts
+5
-0
SceneManager.ts
fe/src/SceneManager.ts
+6
-1
GameoverScene.ts
fe/src/scenes/GameoverScene.ts
+109
-0
RoomScene.ts
fe/src/scenes/RoomScene.ts
+6
-2
No files found.
fe/src/Main.ts
View file @
480f2513
...
...
@@ -137,6 +137,11 @@ class Main extends egret.DisplayObjectContainer {
break
;
case
'game_ready'
:
SceneManager
.
getInstance
().
roomScene
.
update
(
data
)
break
;
case
'game_end'
:
SceneManager
.
getInstance
().
changeScene
(
'gameoverScene'
)
SceneManager
.
getInstance
().
gameoverScene
.
update
(
data
)
break
;
}
})
platform
.
onSocketError
((
e
)
=>
{
...
...
fe/src/SceneManager.ts
View file @
480f2513
...
...
@@ -5,9 +5,12 @@ class SceneManager extends egret.DisplayObjectContainer {
public
roomScene
:
RoomScene
;
// 游戏场景
public
gameScene
:
GameScene
;
// 游戏结束场景
public
gameoverScene
:
GameoverScene
;
private
sceneMap
:
any
=
{
roomScene
:
RoomScene
,
gameScene
:
GameScene
gameScene
:
GameScene
,
gameoverScene
:
GameoverScene
}
public
constructor
()
{
...
...
@@ -17,8 +20,10 @@ class SceneManager extends egret.DisplayObjectContainer {
private
init
()
{
// 实例化两个场景
this
.
roomScene
=
new
RoomScene
();
this
.
gameoverScene
=
new
GameoverScene
();
// this.gameScene = new GameScene();
// 默认添加开始场景
// this.addChild(this.gameoverScene);
this
.
addChild
(
this
.
roomScene
);
}
// 实例化单例获取方法
...
...
fe/src/scenes/GameoverScene.ts
0 → 100644
View file @
480f2513
class
GameoverScene
extends
egret
.
Sprite
{
private
startLabel
:
egret
.
TextField
private
players
:
Array
<
any
>
private
avatars
:
any
public
constructor
()
{
super
();
this
.
init
()
}
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
console
.
log
(
'GameoverScene.init'
)
this
.
initBg
()
this
.
initEndLabel
()
this
.
initBackLabel
()
}
public
update
(
data
)
{
const
payload
=
data
.
payload
switch
(
data
.
type
)
{
case
'game_end'
:
default
:
break
;
}
}
private
initBackLabel
()
{
var
backLabel
=
new
egret
.
TextField
()
backLabel
.
text
=
'< 返回'
backLabel
.
x
=
50
backLabel
.
y
=
680
backLabel
.
bold
=
true
backLabel
.
touchEnabled
=
true
backLabel
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
backHandler
,
this
)
this
.
addChild
(
backLabel
)
}
private
backHandler
()
{
platform
.
sendSocketMessage
({
data
:
JSON
.
stringify
({
type
:
'entry'
,
room_id
:
'default_room'
,
payload
:
{
avatar_url
:
Store
.
getState
().
userInfo
.
avatarUrl
,
nick_name
:
Store
.
getState
().
userInfo
.
nickName
}
}),
success
:
res
=>
{
console
.
error
(
"entry success"
)
},
fail
:
res
=>
{
console
.
error
(
"entry fail"
)
},
complete
:
res
=>
{
}
})
SceneManager
.
getInstance
().
changeScene
(
'roomScene'
)
}
private
initCountDown
(
res
)
{
var
cdText
=
new
egret
.
TextField
()
cdText
.
text
=
'10'
const
timer
=
setInterval
(()
=>
{
if
(
cdText
.
text
==
'0'
)
{
clearInterval
(
timer
)
SceneManager
.
getInstance
().
changeScene
(
'roomScene'
)
return
}
cdText
.
text
=
`
${
Number
(
cdText
.
text
)
-
1
}
`
},
1000
)
}
private
initBg
()
{
var
shape
:
egret
.
Shape
=
new
egret
.
Shape
();
shape
.
graphics
.
beginFill
(
0x343E5F
);
shape
.
graphics
.
drawRect
(
0
,
0
,
2000
,
2000
);
shape
.
graphics
.
endFill
();
this
.
addChild
(
shape
);
// var bg: egret.Bitmap = new egret.Bitmap()
// bg.texture = RES.getRes("logo_jpg")
// bg.scaleX = bg.scaleY = 2
// bg.x = 1334 / 2 - 280
// bg.y = 100
// this.addChild(bg)
}
private
initEndLabel
()
{
var
gameoverText
=
new
egret
.
TextField
()
gameoverText
.
textColor
=
0xF0D66D
gameoverText
.
strokeColor
=
0xffff00
gameoverText
.
stroke
=
5
gameoverText
.
text
=
"GAME OVER"
gameoverText
.
size
=
100
gameoverText
.
width
=
700
gameoverText
.
anchorOffsetX
=
350
gameoverText
.
x
=
1334
/
2
gameoverText
.
textAlign
=
egret
.
HorizontalAlign
.
CENTER
;
gameoverText
.
y
=
100
this
.
addChild
(
gameoverText
);
}
public
release
()
{
// 移除事件
}
}
fe/src/scenes/RoomScene.ts
View file @
480f2513
...
...
@@ -33,9 +33,9 @@ class RoomScene extends egret.Sprite {
}
public
update
(
data
)
{
const
payload
=
data
.
payload
switch
(
data
.
type
)
{
case
'entry'
:
const
payload
=
data
.
payload
this
.
updateStartLabelAndPlayers
(
payload
)
break
;
case
'game_ready'
:
...
...
@@ -47,6 +47,7 @@ class RoomScene extends egret.Sprite {
}
private
updateStartLabelAndPlayers
(
payload
)
{
const
{
seat
,
members
,
nick_name
}
=
payload
if
(
payload
.
seat
==
0
)
{
this
.
startLabel
.
text
=
'开始'
this
.
startLabel
.
touchEnabled
=
true
...
...
@@ -55,7 +56,6 @@ class RoomScene extends egret.Sprite {
this
.
startLabel
.
text
=
'等待房主点击开始'
this
.
startLabel
.
touchEnabled
=
false
}
const
members
=
payload
.
members
if
(
this
.
avatars
&&
this
.
avatars
.
parent
){
this
.
avatars
.
parent
.
removeChild
(
this
.
avatars
)
}
...
...
@@ -66,9 +66,12 @@ class RoomScene extends egret.Sprite {
}
private
countDown
(
res
)
{
this
.
startLabel
.
bold
=
true
this
.
startLabel
.
text
=
'3'
this
.
startLabel
.
size
=
50
const
timer
=
setInterval
(()
=>
{
if
(
this
.
startLabel
.
text
==
'1'
)
{
this
.
startLabel
.
size
=
this
.
startLabel
.
size
+
20
return
this
.
startLabel
.
text
=
'Go!'
}
if
(
this
.
startLabel
.
text
==
'Go!'
)
{
...
...
@@ -80,6 +83,7 @@ class RoomScene extends egret.Sprite {
return
}
this
.
startLabel
.
text
=
`
${
Number
(
this
.
startLabel
.
text
)
-
1
}
`
this
.
startLabel
.
size
=
this
.
startLabel
.
size
+
10
},
1000
)
}
...
...
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