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
1fc27b70
Commit
1fc27b70
authored
May 05, 2018
by
Mike Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update RoomScene
parent
d68283ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
5 deletions
+63
-5
Platform.ts
fe/src/Platform.ts
+9
-0
Store.ts
fe/src/Store.ts
+9
-1
RoomScene.ts
fe/src/scenes/RoomScene.ts
+36
-4
platform.js
fe_wxgame/platform.js
+9
-0
No files found.
fe/src/Platform.ts
View file @
1fc27b70
...
...
@@ -13,10 +13,12 @@ declare interface Platform {
connectSocket
(
options
):
void
onSocketOpen
(
callback
):
void
onSocketClose
(
callback
):
void
closeSocket
(
options
):
void
onSocketMessage
(
callback
):
void
onSocketError
(
callback
):
void
sendSocketMessage
(
callback
):
void
request
(
options
):
void
exitMiniProgram
(
options
):
void
}
class
DebugPlatform
implements
Platform
{
...
...
@@ -43,6 +45,10 @@ class DebugPlatform implements Platform {
}
closeSocket
(
options
){
}
onSocketMessage
(
options
){
}
...
...
@@ -57,6 +63,9 @@ class DebugPlatform implements Platform {
request
(){
}
exitMiniProgram
(
options
){
}
}
...
...
fe/src/Store.ts
View file @
1fc27b70
...
...
@@ -22,7 +22,15 @@ class Store {
}
break
;
case
'setUserInfo'
:
_state
.
userInfo
=
message
.
data
_state
=
{
...
_state
,
userInfo
:
payload
}
case
'updateCid'
:
_state
=
{
...
_state
,
cid
:
payload
.
cid
}
default
:
break
;
}
...
...
fe/src/scenes/RoomScene.ts
View file @
1fc27b70
...
...
@@ -20,10 +20,13 @@ class RoomScene extends egret.Sprite {
public
update
(
data
)
{
const
payload
=
data
.
payload
if
(
payload
.
seat
==
0
)
{
if
(
payload
.
seat
==
0
)
{
this
.
startLabel
.
text
=
'开始'
this
.
startLabel
.
touchEnabled
=
true
this
.
startLabel
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
startHandler
,
this
)
}
else
{
this
.
startLabel
.
text
=
'等待房主点击开始'
this
.
startLabel
.
touchEnabled
=
false
}
}
...
...
@@ -44,8 +47,8 @@ class RoomScene extends egret.Sprite {
this
.
startLabel
=
new
egret
.
TextField
()
this
.
startLabel
.
textColor
=
0xF0D66D
this
.
startLabel
.
text
=
"请稍等..."
this
.
startLabel
.
width
=
2
00
this
.
startLabel
.
anchorOffsetX
=
1
0
0
this
.
startLabel
.
width
=
3
00
this
.
startLabel
.
anchorOffsetX
=
1
5
0
this
.
startLabel
.
x
=
1334
/
2
this
.
startLabel
.
textAlign
=
egret
.
HorizontalAlign
.
CENTER
;
this
.
startLabel
.
y
=
1136
/
2
...
...
@@ -53,10 +56,38 @@ class RoomScene extends egret.Sprite {
private
startHandler
()
{
console
.
log
(
'starthandler'
)
SceneManager
.
getInstance
().
changeScene
(
'gameScene'
);
platform
.
sendSocketMessage
({
data
:
JSON
.
stringify
({
type
:
'start'
,
rid
:
'default_room'
,
cid
:
Store
.
getState
().
cid
,
payload
:
{
avatar_url
:
Store
.
getState
().
userInfo
.
avatarUrl
,
nick_name
:
Store
.
getState
().
userInfo
.
nickName
}
}),
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
=
'启动失败'
}
})
}
public
release
()
{
// 移除事件
this
.
startLabel
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
startHandler
,
this
)
}
}
\ No newline at end of file
fe_wxgame/platform.js
View file @
1fc27b70
...
...
@@ -46,6 +46,10 @@ class WxgamePlatform {
wx
.
onSocketClose
(
callback
)
}
closeSocket
(
options
){
wx
.
closeSocket
(
options
)
}
onSocketMessage
(
callback
){
wx
.
onSocketMessage
(
callback
)
}
...
...
@@ -57,9 +61,14 @@ class WxgamePlatform {
sendSocketMessage
(
options
){
wx
.
sendSocketMessage
(
options
)
}
request
(
options
){
wx
.
request
(
options
)
}
exitMiniProgram
(
options
){
wx
.
exitMiniProgram
(
options
)
}
}
...
...
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