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
1f4ef36c
Commit
1f4ef36c
authored
May 06, 2018
by
Mike Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新游戏排行
parent
942afd4d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
15 deletions
+94
-15
Rank.ts
fe/src/Rank.ts
+33
-0
RankGroup.ts
fe/src/RankGroup.ts
+30
-0
GameoverScene.ts
fe/src/scenes/GameoverScene.ts
+29
-15
RoomScene.ts
fe/src/scenes/RoomScene.ts
+2
-0
No files found.
fe/src/Rank.ts
0 → 100644
View file @
1f4ef36c
class
Rank
extends
egret
.
Sprite
{
public
constructor
(
userData
)
{
super
()
this
.
init
(
userData
)
}
private
avatar
=
new
egret
.
Bitmap
()
private
bg
=
new
egret
.
Bitmap
()
private
imageLoader
=
new
egret
.
ImageLoader
()
private
init
(
userData
)
{
this
.
bg
.
width
=
100
this
.
bg
.
height
=
100
this
.
bg
.
texture
=
RES
.
getRes
(
"avatar_bg_jpg"
)
this
.
addChild
(
this
.
bg
)
this
.
avatar
.
x
=
10
this
.
avatar
.
y
=
10
this
.
avatar
.
width
=
80
this
.
avatar
.
height
=
80
this
.
imageLoader
.
addEventListener
(
egret
.
Event
.
COMPLETE
,
this
.
loadCompleteHandler
,
this
)
this
.
imageLoader
.
load
(
userData
.
avatar_url
||
"http://www.insajderi.com/wp-content/uploads/2018/01/asdja.jpg"
)
this
.
addChild
(
this
.
avatar
)
}
private
loadCompleteHandler
()
{
let
texture
=
new
egret
.
Texture
()
texture
.
_setBitmapData
(
this
.
imageLoader
.
data
)
this
.
avatar
.
texture
=
texture
}
}
fe/src/RankGroup.ts
0 → 100644
View file @
1f4ef36c
class
RankGroup
extends
egret
.
Sprite
{
public
constructor
(
ranks
)
{
super
()
this
.
init
(
ranks
)
}
private
init
(
ranks
)
{
ranks
.
forEach
((
rank
,
index
)
=>
{
let
yPosition
=
index
*
100
let
avatar
=
new
Avatar
(
rank
[
0
])
avatar
.
y
=
yPosition
this
.
addChild
(
avatar
)
let
name
=
new
egret
.
TextField
()
name
.
text
=
rank
[
0
].
nick_name
name
.
y
=
yPosition
+
40
name
.
x
=
120
this
.
addChild
(
name
)
let
score
=
new
egret
.
TextField
()
score
.
text
=
rank
[
1
]
score
.
y
=
yPosition
+
40
score
.
x
=
500
this
.
addChild
(
score
)
})
}
}
\ No newline at end of file
fe/src/scenes/GameoverScene.ts
View file @
1f4ef36c
class
GameoverScene
extends
egret
.
Sprite
{
class
GameoverScene
extends
egret
.
Sprite
{
private
startLabel
:
egret
.
TextField
private
startLabel
:
egret
.
TextField
private
players
:
Array
<
any
>
private
rankGroup
:
any
private
avatars
:
any
public
constructor
()
{
public
constructor
()
{
super
();
super
();
...
@@ -15,19 +15,33 @@ class GameoverScene extends egret.Sprite {
...
@@ -15,19 +15,33 @@ class GameoverScene extends egret.Sprite {
this
.
initBg
()
this
.
initBg
()
this
.
initEndLabel
()
this
.
initEndLabel
()
this
.
initBackLabel
()
this
.
initBackLabel
()
// this.initRankGroup()
}
}
public
update
(
data
)
{
public
update
(
data
)
{
const
payload
=
data
.
payload
const
payload
=
data
.
payload
switch
(
data
.
type
)
{
switch
(
data
.
type
)
{
case
'game_end'
:
case
'game_end'
:
this
.
updateRank
(
payload
)
default
:
default
:
break
;
break
;
}
}
}
}
private
updateRank
(
data
)
{
if
(
this
.
rankGroup
&&
this
.
rankGroup
.
parent
)
{
this
.
rankGroup
.
parent
.
removeChild
(
this
.
rankGroup
)
}
this
.
rankGroup
=
new
RankGroup
(
data
.
rank
)
this
.
rankGroup
.
x
=
400
this
.
rankGroup
.
y
=
250
this
.
addChild
(
this
.
rankGroup
)
}
// private initRankGroup() {
// this.rankGroup
// }
private
initBackLabel
()
{
private
initBackLabel
()
{
var
backLabel
=
new
egret
.
TextField
()
var
backLabel
=
new
egret
.
TextField
()
backLabel
.
text
=
'< 返回'
backLabel
.
text
=
'< 返回'
...
@@ -61,18 +75,18 @@ class GameoverScene extends egret.Sprite {
...
@@ -61,18 +75,18 @@ class GameoverScene extends egret.Sprite {
})
})
SceneManager
.
getInstance
().
changeScene
(
'roomScene'
)
SceneManager
.
getInstance
().
changeScene
(
'roomScene'
)
}
}
private
initCountDown
(
res
)
{
//
private initCountDown(res) {
var
cdText
=
new
egret
.
TextField
()
//
var cdText = new egret.TextField()
cdText
.
text
=
'10'
//
cdText.text = '10'
const
timer
=
setInterval
(()
=>
{
//
const timer = setInterval(() => {
if
(
cdText
.
text
==
'0'
)
{
//
if (cdText.text == '0') {
clearInterval
(
timer
)
//
clearInterval(timer)
SceneManager
.
getInstance
().
changeScene
(
'roomScene'
)
//
SceneManager.getInstance().changeScene('roomScene')
return
//
return
}
//
}
cdText
.
text
=
`
${
Number
(
cdText
.
text
)
-
1
}
`
//
cdText.text = `${Number(cdText.text) - 1}`
},
1000
)
//
}, 1000)
}
//
}
private
initBg
()
{
private
initBg
()
{
var
shape
:
egret
.
Shape
=
new
egret
.
Shape
();
var
shape
:
egret
.
Shape
=
new
egret
.
Shape
();
...
...
fe/src/scenes/RoomScene.ts
View file @
1f4ef36c
...
@@ -49,10 +49,12 @@ class RoomScene extends egret.Sprite {
...
@@ -49,10 +49,12 @@ class RoomScene extends egret.Sprite {
private
updateStartLabelAndPlayers
(
payload
)
{
private
updateStartLabelAndPlayers
(
payload
)
{
const
{
seat
,
members
,
nick_name
}
=
payload
const
{
seat
,
members
,
nick_name
}
=
payload
if
(
payload
.
seat
==
0
)
{
if
(
payload
.
seat
==
0
)
{
this
.
startLabel
.
size
=
egret
.
TextField
.
default_size
this
.
startLabel
.
text
=
'开始'
this
.
startLabel
.
text
=
'开始'
this
.
startLabel
.
touchEnabled
=
true
this
.
startLabel
.
touchEnabled
=
true
this
.
startLabel
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
startHandler
,
this
)
this
.
startLabel
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
startHandler
,
this
)
}
else
{
}
else
{
this
.
startLabel
.
size
=
egret
.
TextField
.
default_size
this
.
startLabel
.
text
=
'等待房主点击开始'
this
.
startLabel
.
text
=
'等待房主点击开始'
this
.
startLabel
.
touchEnabled
=
false
this
.
startLabel
.
touchEnabled
=
false
}
}
...
...
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