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 {
...
@@ -109,20 +109,23 @@ class Main extends egret.DisplayObjectContainer {
})
})
this
.
createGameScene
();
this
.
createGameScene
();
platform
.
onSocketMessage
(
function
(
res
)
{
platform
.
onSocketMessage
(
function
(
res
)
{
console
.
log
(
'收到服务器内容:'
+
res
.
data
)
console
.
log
(
'收到服务器内容:'
+
res
.
data
)
const
state
=
Store
.
onMessage
(
res
.
data
)
const
state
=
Store
.
onMessage
(
res
.
data
)
let
data
=
res
.
data
let
data
=
res
.
data
if
(
typeof
res
.
data
===
'string'
)
{
if
(
typeof
res
.
data
===
'string'
)
{
data
=
JSON
.
parse
(
res
.
data
)
data
=
JSON
.
parse
(
res
.
data
)
}
switch
(
data
.
type
)
{
case
'entry'
:
if
(
data
.
type
===
'entry'
)
{
Store
.
onMessage
({
Store
.
onMessage
({
type
:
'updateCid'
,
type
:
'updateCid'
,
payload
:
data
payload
:
data
})
})
SceneManager
.
getInstance
().
roomScene
.
update
(
data
)
SceneManager
.
getInstance
().
roomScene
.
update
(
data
)
break
;
case
'game_ready'
:
SceneManager
.
getInstance
().
roomScene
.
update
(
data
)
}
}
}
})
})
platform
.
onSocketError
((
e
)
=>
{
platform
.
onSocketError
((
e
)
=>
{
...
...
fe/src/Store.ts
View file @
461a7523
...
@@ -26,11 +26,13 @@ class Store {
...
@@ -26,11 +26,13 @@ class Store {
...
_state
,
...
_state
,
userInfo
:
payload
userInfo
:
payload
}
}
break
;
case
'updateCid'
:
case
'updateCid'
:
_state
=
{
_state
=
{
...
_state
,
...
_state
,
cid
:
payload
.
cid
cid
:
payload
.
cid
}
}
break
;
default
:
default
:
break
;
break
;
}
}
...
...
fe/src/scenes/RoomScene.ts
View file @
461a7523
...
@@ -19,6 +19,8 @@ class RoomScene extends egret.Sprite {
...
@@ -19,6 +19,8 @@ class RoomScene extends egret.Sprite {
}
}
public
update
(
data
)
{
public
update
(
data
)
{
switch
(
data
.
type
)
{
case
'entry'
:
const
payload
=
data
.
payload
const
payload
=
data
.
payload
if
(
payload
.
seat
==
0
)
{
if
(
payload
.
seat
==
0
)
{
this
.
startLabel
.
text
=
'开始'
this
.
startLabel
.
text
=
'开始'
...
@@ -28,6 +30,28 @@ class RoomScene extends egret.Sprite {
...
@@ -28,6 +30,28 @@ class RoomScene extends egret.Sprite {
this
.
startLabel
.
text
=
'等待房主点击开始'
this
.
startLabel
.
text
=
'等待房主点击开始'
this
.
startLabel
.
touchEnabled
=
false
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
()
{
private
initBg
()
{
...
@@ -67,21 +91,10 @@ class RoomScene extends egret.Sprite {
...
@@ -67,21 +91,10 @@ class RoomScene extends egret.Sprite {
}
}
}),
}),
success
:
res
=>
{
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
=>
{
fail
:
res
=>
{
this
.
startLabel
.
text
=
'启动失败'
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