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
461a7523
Commit
461a7523
authored
May 05, 2018
by
Mike Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新所有玩家倒计时
parent
9ff81dfe
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
16 deletions
+34
-16
Main.ts
fe/src/Main.ts
+7
-4
Store.ts
fe/src/Store.ts
+2
-0
RoomScene.ts
fe/src/scenes/RoomScene.ts
+25
-12
No files found.
fe/src/Main.ts
View file @
461a7523
...
...
@@ -109,20 +109,23 @@ class Main extends egret.DisplayObjectContainer {
})
this
.
createGameScene
();
platform
.
onSocketMessage
(
function
(
res
)
{
platform
.
onSocketMessage
(
function
(
res
)
{
console
.
log
(
'收到服务器内容:'
+
res
.
data
)
const
state
=
Store
.
onMessage
(
res
.
data
)
let
data
=
res
.
data
if
(
typeof
res
.
data
===
'string'
)
{
data
=
JSON
.
parse
(
res
.
data
)
}
if
(
data
.
type
===
'entry'
)
{
switch
(
data
.
type
)
{
case
'entry'
:
Store
.
onMessage
({
type
:
'updateCid'
,
payload
:
data
})
SceneManager
.
getInstance
().
roomScene
.
update
(
data
)
break
;
case
'game_ready'
:
SceneManager
.
getInstance
().
roomScene
.
update
(
data
)
}
}
})
platform
.
onSocketError
((
e
)
=>
{
...
...
fe/src/Store.ts
View file @
461a7523
...
...
@@ -26,11 +26,13 @@ class Store {
...
_state
,
userInfo
:
payload
}
break
;
case
'updateCid'
:
_state
=
{
...
_state
,
cid
:
payload
.
cid
}
break
;
default
:
break
;
}
...
...
fe/src/scenes/RoomScene.ts
View file @
461a7523
...
...
@@ -19,6 +19,8 @@ class RoomScene extends egret.Sprite {
}
public
update
(
data
)
{
switch
(
data
.
type
)
{
case
'entry'
:
const
payload
=
data
.
payload
if
(
payload
.
seat
==
0
)
{
this
.
startLabel
.
text
=
'开始'
...
...
@@ -28,6 +30,28 @@ class RoomScene extends egret.Sprite {
this
.
startLabel
.
text
=
'等待房主点击开始'
this
.
startLabel
.
touchEnabled
=
false
}
break
;
case
'game_ready'
:
this
.
countDown
(
payload
)
default
:
break
;
}
}
private
countDown
(
res
)
{
this
.
startLabel
.
text
=
'3'
const
timer
=
setInterval
(()
=>
{
if
(
this
.
startLabel
.
text
==
'1'
)
{
return
this
.
startLabel
.
text
=
'Go!'
}
if
(
this
.
startLabel
.
text
==
'Go!'
)
{
clearInterval
(
timer
)
SceneManager
.
getInstance
().
changeScene
(
'gameScene'
)
return
}
this
.
startLabel
.
text
=
`
${
Number
(
this
.
startLabel
.
text
)
-
1
}
`
},
1000
)
}
private
initBg
()
{
...
...
@@ -67,21 +91,10 @@ class RoomScene extends egret.Sprite {
}
}),
success
:
res
=>
{
this
.
startLabel
.
text
=
'3'
const
timer
=
setInterval
(()
=>
{
if
(
this
.
startLabel
.
text
==
'1'
)
{
return
this
.
startLabel
.
text
=
'Go!'
}
if
(
this
.
startLabel
.
text
==
'Go!'
)
{
clearInterval
(
timer
)
SceneManager
.
getInstance
().
changeScene
(
'gameScene'
)
return
}
this
.
startLabel
.
text
=
`
${
Number
(
this
.
startLabel
.
text
)
-
1
}
`
},
1000
)
},
fail
:
res
=>
{
this
.
startLabel
.
text
=
'启动失败'
console
.
error
(
'start error: '
,
res
)
}
})
}
...
...
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